c-exercises/undefined-behaviour.c

17 lines
317 B
C
Raw Normal View History

2014-02-15 14:09:43 +01:00
#include <stdio.h>
int main(void) {
int a = 5;
int b = a + 7;
int c = a - b + 7;
// c is zero now!
printf("c = %i\n", c);
// Depending on e.g. the optimization level, this either throws a
// floating point exception or does other things like returning 10.
if (3/c > 4)
return 5;
return 10;
}