Hello, g++-current ( [trunk revision 143790] ) produce incorrect warning. Need I file bug-report?
# g++ -Wall -O2 -c test3.cpp test3.cpp: In function 'void bar()': test3.cpp:16: warning: dereferencing pointer '<anonymous>' does break strict-aliasing rules /usr/local/gcc_current/lib/gcc/i686-pc-linux-gnu/4.4.0/include/c++/bits/stl_list.h:139: note: initialized from here # pr -n test3.cpp 1 #include <string> 2 #include <list> 3 4 class A; 5 6 class B { 7 public: 8 void foo(A&); 9 std::string s; 10 }; 11 12 class A { 13 public: 14 A& qaz() { 15 l.push_back( new A() ); 16 return *l.back(); 17 } 18 std::list<A*> l; 19 }; 20 21 void bar() 22 { 23 A a; 24 B b; 25 b.foo(a.qaz()); 26 } [r...@localhost gcc_err]# g++ -v Using built-in specs. Target: i686-pc-linux-gnu Configured with: ../gcc_current/configure --prefix=/usr/local/gcc_current --enable-shared --enable-threads=posix --enable-checking=release --enable-__cxa_atexit --enable-version-specific-runtime-libs --enable-languages=c,c++ : (reconfigured) ../gcc_current/configure --prefix=/usr/local/gcc_current --enable-shared --enable-threads=posix --enable-checking=release --enable-__cxa_atexit --enable-version-specific-runtime-libs --enable-languages=c,c++ --no-create --no-recursion : (reconfigured) ../gcc_current/configure --prefix=/usr/local/gcc_current --enable-shared --enable-threads=posix --enable-checking=release --enable-__cxa_atexit --enable-version-specific-runtime-libs --enable-languages=c,c++ --no-create --no-recursion : (reconfigured) ../gcc_current/configure --prefix=/usr/local/gcc_current --enable-shared --enable-threads=posix --enable-checking=release --enable-__cxa_atexit --enable-version-specific-runtime-libs --enable-languages=c,c++ --no-create --no-recursion : (reconfigured) ../gcc_current/configure --prefix=/usr/local/gcc_current --enable-shared --enable-threads=posix --enable-checking=release --enable-__cxa_atexit --enable-version-specific-runtime-libs --enable-languages=c,c++ --no-create --no-recursion : (reconfigured) ../gcc_current/configure --prefix=/usr/local/gcc_current --enable-shared --enable-threads=posix --enable-checking=release --enable-__cxa_atexit --enable-version-specific-runtime-libs --enable-languages=c,c++ --no-create --no-recursion : (reconfigured) ../gcc_current/configure --prefix=/usr/local/gcc_current --enable-shared --enable-threads=posix --enable-checking=release --enable-__cxa_atexit --enable-version-specific-runtime-libs --enable-languages=c,c++ --no-create --no-recursion : (reconfigured) ../gcc_current/configure --prefix=/usr/local/gcc_current --enable-shared --enable-threads=posix --enable-checking=release --enable-__cxa_atexit --enable-version-specific-runtime-libs --enable-languages=c,c++ --no-create --no-recursion : (reconfigured) ../gcc_current/configure --prefix=/usr/local/gcc_current --enable-shared --enable-threads=posix --enable-checking=release --enable-__cxa_atexit --enable-version-specific-runtime-libs --enable-languages=c,c++ --no-create --no-recursion : (reconfigured) ../gcc_current/configure --prefix=/usr/local/gcc_current --enable-shared --enable-threads=posix --enable-checking=release --enable-__cxa_atexit --enable-version-specific-runtime-libs --enable-languages=c,c++ --no-create --no-recursion : (reconfigured) ../gcc_current/configure --prefix=/usr/local/gcc_current --enable-shared --enable-threads=posix --enable-checking=release --enable-__cxa_atexit --enable-version-specific-runtime-libs --enable-languages=c,c++ --no-create --no-recursion : (reconfigured) ../gcc_current/configure --prefix=/usr/local/gcc_current --enable-shared --enable-threads=posix --enable-checking=release --enable-__cxa_atexit --enable-version-specific-runtime-libs --enable-languages=c,c++ --no-create --no-recursion : (reconfigured) ../gcc_current/configure --prefix=/usr/local/gcc_current --enable-shared --enable-threads=posix --enable-checking=release --enable-__cxa_atexit --enable-version-specific-runtime-libs --enable-languages=c,c++ --no-create --no-recursion : (reconfigured) ../gcc_current/configure --prefix=/usr/local/gcc_current --enable-shared --enable-threads=posix --enable-checking=release --enable-__cxa_atexit --enable-version-specific-runtime-libs --enable-languages=c,c++ --no-create --no-recursion : (reconfigured) ../gcc_current/configure --prefix=/usr/local/gcc_current --enable-shared --enable-threads=posix --enable-checking=release --enable-__cxa_atexit --enable-version-specific-runtime-libs --enable-languages=c,c++ --no-create --no-recursion : (reconfigured) ../gcc_current/configure --prefix=/usr/local/gcc_current --enable-shared --enable-threads=posix --enable-checking=release --enable-__cxa_atexit --enable-version-specific-runtime-libs --enable-languages=c,c++ --no-create --no-recursion : (reconfigured) ../gcc_current/configure --prefix=/usr/local/gcc_current --enable-shared --enable-threads=posix --enable-checking=release --enable-__cxa_atexit --enable-version-specific-runtime-libs --enable-languages=c,c++ --no-create --no-recursion Thread model: posix gcc version 4.4.0 20090130 (experimental) [trunk revision 143790] (GCC) # uname -a Linux localhost.localdomain 2.6.26.8-57.fc8 #1 SMP Thu Dec 18 19:19:45 EST 2008 i686 i686 i386 GNU/Linux