Hi, I recently ran into an issue with an uninitialized pointer which I
expected g++ to warn about.
class Foo {
public:
Foo* a(){ return this; }
};
int main(int argc, const char*[] ){
for ( int i = 0; i < 6; i++ ){
Foo* foo = foo->a();
}
}
This code compiles without any warnings (with -Wall) with both g++-4.4.2
and g++-4.2.4. Removing the for-loop gives me a warning as expected:
foo.cpp: In function ‘int main(int, const char**)’:
foo.cpp:8: warning: ‘foo’ is used uninitialized in this function
I know this case is a bit silly but it happened because of a typo and
went unnoticed for a while.
Is my reasoning flawed or should g++ emit a warning?