This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/45289] gcc lacks a "posix" option for "-std" since POSIX 2008 defines special behavior
- From: "jakub at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 15 Aug 2010 21:33:59 -0000
- Subject: [Bug c/45289] gcc lacks a "posix" option for "-std" since POSIX 2008 defines special behavior
- References: <bug-45289-19569@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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