This is the mail archive of the
mailing list for the GCC project.
Re: Strict aliasing and pointers to functions
On Sun, 26 Nov 2006, Andrew Haley wrote:
void (*fptr) (void);
bilge.barf = dlsym (NULL, "dummy");
funcs.dummy = bilge.fptr;
The only thing, conformance wise, that can be different here is the
fact that (according to the link bellow) type-prunning is allowed
for unions. This does not change the fact that `void *' and any
pointer to function are incompatible.
However i'm not targetting standard C (i wouldn't know if it's possible
to implement `dlsym' without falling into undefined/specified behavior
on such a system at all).
> P.S. It seems like i can use the tripple casting trick once again
> instead of straightforward `struct.field', but this again begs
> the question of portability/conformance.
Why are you using the "triple casting trick"? All it can possibly do
is silence a warning; it won't make the code correct.
Less typing and: