public
Created

G++ missing warning

  • Download Gist
uninit.c
C
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#include <stdio.h>
#include <stdlib.h>
 
int main()
{
int a, b;
float f, g = 1;
if(rand() < 0.5) {
b = 0;
} else {
b = 5;
}
for(a = 0; a < b; ++a) {
/* you would expect the following line to trigger a warning "f is used uninitialized"...
but that doesn't happen without optimization (-O)! */
f = f + a;
}
g += f;
printf("%f\n", g);
return 0;
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.