As originally reported at
http://lists.opensuse.org/opensuse-packaging/2010-08/msg00038.html POSIX 2008
says
(http://www.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_12_03):

"2.12.3 Pointer Types

All function pointer types shall have the same representation as the type
pointer to void. Conversion of a function pointer to void * shall not alter the
representation. A void * value resulting from such a conversion can be
converted back to the original function pointer type, using an explicit cast,
without loss of information.

Note:
    The ISO C standard does not require this, but it is required for POSIX
conformance."

When compiling the example code for dlsym
(http://www.opengroup.org/onlinepubs/9699919799/functions/dlsym.html) gcc
complains with: "warning: dereferencing type-punned pointer will break
strict-aliasing rules".

Not sure how this applies for C++, but g++ outputs the same warning.


The suggested fix is to add a posix/posix2008 mode and make that the default
for "platforms that are supposed to be POSIX", specifically Linux.


-- 
           Summary: gcc lacks a "posix" option for "-std" since POSIX 2008
                    defines special behavior
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: reddwarf at opensuse dot org


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

Reply via email to