
Untitled
By: a guest on
Jul 1st, 2012 | syntax:
None | size: 0.78 KB | hits: 20 | expires: Never
Why does g warning about uninitialized variable depend on the type of the variable? (it warns for an int but not for a double)
#include <iostream>
typedef double barType;
struct foo {
barType bar;
};
int main() {
foo f;
std::cout << f.bar << std::endl;
}
$ g++ -O1 -Wall test.cc -o test
$ g++ -O1 -Wall test.cc -o test
test.cc: In function ‘int main()’:
test.cc:17: warning: ‘f.foo::bar’ is used uninitialized in this function
$ g++ --version
g++ (Ubuntu 4.4.1-4ubuntu9) 4.4.1
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
cc1plus: warning: -Wuninitialized is not supported without -O