#include <cstdio> int main() { int x = 0x80000000; std::printf( "%08x\n", x ); x *= 2; std::printf( "%08x\n", x ); // still here? std::puts( "-ftrapv doesn't work :(" ); return 0; }
$ g++ signed_overflow_3.cpp; ./a.out; echo $? 80000000 00000000 -ftrapv doesn't work :( 0 gcc version 4.1.1 20060419 (prerelease) -- Summary: -ftrapv doesn't work. Product: gcc Version: 4.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: other AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: pluto at agmk dot net GCC build triplet: x86-64-linux GCC host triplet: x86-64-linux GCC target triplet: x86-64-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27261