Another problem with aliasing: The following code snippet triggers a bogus warning when compiled on trunk with "-O -Wall":
========================================================================== #include<set> struct A { A() : i() {} int i; }; struct B { bool operator() (const A& x, const A& y) const { return x.i < y.i; } }; void foo() { std::set<A, B> s; s.insert(A()); } ========================================================================== bug.cc: In function 'void foo()': bug.cc:11: warning: dereferencing pointer '__x.15' does break strict-aliasing rules .../gcc-4.4-20090305/include/c++/4.4.0/bits/stl_tree.h:530: note: initialized from here bug.cc:11: warning: dereferencing pointer '__x.15' does break strict-aliasing rules .../gcc-4.4-20090305/include/c++/4.4.0/bits/stl_tree.h:530: note: initialized from here This probably results in wrong code generation. -- Summary: [4.4 regression] Bogus aliasing warning with std::set Product: gcc Version: 4.4.0 Status: UNCONFIRMED Keywords: wrong-code, diagnostic 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=39390