Add an example of undefined behaviour
parent
ed40922f52
commit
ffa93c8d34
@ -0,0 +1,16 @@
|
||||
#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;
|
||||
}
|
Loading…
Reference in New Issue