Skip to content

Instantly share code, notes, and snippets.

@DCoderLT
Created September 23, 2012 07:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DCoderLT/3769253 to your computer and use it in GitHub Desktop.
Save DCoderLT/3769253 to your computer and use it in GitHub Desktop.
G++ missing warning
#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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment