This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/45289] gcc lacks a "posix" option for "-std" since POSIX 2008 defines special behavior



------- Comment #6 from jakub at gcc dot gnu dot org  2010-08-15 21:33 -------
There are more possibilities, like:
3) void (*fnptr) (void); void *p = dlsym (...); memcpy (&fnptr, &p, sizeof
(p)); fnptr ();
The POSIX standard wording doesn't talk about void * and function pointers
being compatible types as used in ISO C99, 6.5.  It only talks about the same
representation and conversion preserving it.  Thus, from this wording, I'd say
the 1) is also valid for POSIX, but not 2).  When the representation is the
same, memcpy should be safe, both from aliasing POV and should DTRT, as
workaround for the warning in 1).


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45289


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]