The following valid code snippet triggers an invalid warning on trunk
when compiled (on i686 or x64) with "-O2 -Wall":
===================================
#include<list>
struct A
{
virtual ~A();
};
A* foo();
void bar(std::list<int> x)
{
std::list<int> y = x;
if (*y.rbegin())
delete foo();
}
===================================
bug.cc: In function 'void bar(std::list<int, std::allocator<int> >)':
bug.cc:13: warning: dereferencing pointer '<anonymous>' does break
strict-aliasing rules
.../gcc-4.4-20090226/include/c++/4.4.0/bits/stl_list.h:139: note: initialized
from here
The problem appeared (on i686) between 2008-11-20 and 2008-12-19.
To me it looks like something is wrong with alias computation,
although I cannot rule out that there might be something wrong
with our list implementationd instead.
In either case that's serious because the result could be wrong code.
--
Summary: [4.4 regression] Wrong aliasing warning with lists
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Keywords: diagnostic, monitored
Severity: normal
Priority: P3
Component: tree-optimization
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=39358