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 other/52609] New: -Wstrict-aliasing / missed diagnostics


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

             Bug #: 52609
           Summary: -Wstrict-aliasing / missed diagnostics
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: other
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: pluto@agmk.net
            Target: x86_64-gnu-linux


void bug1( unsigned* buffer, int index, float w )
{
        *(float*)(&buffer[index])=w;
}

void bug2( unsigned* buffer, int index, float w )
{
        float* ptr=(float*)&buffer[index];
        *ptr=w;
}

accessing unsigned* via float* looks buggy but

$ gcc48 -Wall -Wstrict-aliasing=3 -Wextra -fstrict-aliasing -O2 -S alias-bug.c

reports no warnings.


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