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 middle-end/39322] New: [4.4 regression] Bogus aliasing warning


A IMHO the trunk issues a bogus warning for the following code snippet
when compiling it with "-O2 -Wall" using the C++ frontend:

==============================
int foo()
{
  char a[10];
  int i = *(int*)&a[4];
  int j = *(int*)(a+4);
  return i+j;
}
==============================

bug.cc: In function 'int foo()':
bug.cc:4: warning: dereferencing type-punned pointer will break strict-aliasing
rules

Interestingly, the warning is given only for line 4, but not line 5.
Also the C frontend is not affected.

If there's wrong alias info involved, this might lead to wrong-code bugs.


-- 
           Summary: [4.4 regression] Bogus aliasing warning
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: diagnostic, monitored
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: reichelt at gcc dot gnu dot org


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


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