------- Comment #1 from paolo dot carlini at oracle dot com 2010-08-10 08:17 ------- What happens if you add -Wall to the command line? Current mainline tells me:
u.cc: In function void* foo(void*): u.cc:12:31: warning: dereferencing type-punned pointer will break strict-aliasing rules u.cc: In function void* foo2(void*): u.cc:18:31: warning: dereferencing type-punned pointer will break strict-aliasing rules u.cc:18:55: warning: dereferencing type-punned pointer will break strict-aliasing rules thus, aliasing violations seem more than likely, without having looked at the code in any detail. Also, try passing -fno-strict-aliasing, if something changes for the better, you are pretty sure the code is defective. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45246