Description of problem: Compiling with -O produces a different result: $ cat bla.c #include <stdio.h> int main() { printf( "%d\n", 0 / 0 ); return 0; } $ gcc bla.c bla.c: In function 'main': bla.c:5:21: warning: division by zero [-Wdiv-by-zero] $ ./a.out Floating point exception $ gcc -O bla.c bla.c: In function 'main': bla.c:5:21: warning: division by zero [-Wdiv-by-zero] $ ./a.out 0 Version-Release number of selected component (if applicable): gcc version 4.7.0 20120507 (Red Hat 4.7.0-5) (GCC) How reproducible: Always.
The testcase is invoking undefined behavior, therefore it is invalid and anything can happen.
The behaviour in this case is left up to the implementation. A good implementation should throw an exception at runtime.