Re: Strict aliasing and pointers to functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 26 Nov 2006, Andrew Haley wrote:

[..snip..]
union
{
 void *barf;
 void (*fptr) (void);
} bilge;

 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).

http://standards.ieee.org/reading/ieee/interp/1003.1-2001/1003.1-2001-04.html


> 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:
 http://www.opensolaris.org/jive/thread.jspa?threadID=1923&tstart=0

--
vale

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux