[Bug c/56523] -Wunitialized is described to be enabled by -Wall

2013-03-04 Thread paolo.carlini at oracle dot com

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56523

--- Comment #1 from Paolo Carlini paolo.carlini at oracle dot com 2013-03-04 
16:16:16 UTC ---
On which basis do you think it doesn't? In practice, for a stupid example like
the below, with -Wall:

int main()
{
  int a;
  return a;
}

I get:

test.c: In function ‘main’:
test.c:4:3: warning: ‘a’ is used uninitialized in this function
[-Wuninitialized]


[Bug c/56523] -Wunitialized is described to be enabled by -Wall

2013-03-04 Thread corentinjabot at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56523



--- Comment #2 from corentinjabot at gmail dot com 2013-03-04 17:33:26 UTC ---

Actually after a few more test it works correctly but the statement This

enables some extra warning flags that are not enabled by -Wall. is confusing

since the to set of options overlap. 



I also tested with the following c++ snippet:



#include iostream

class A {

public:

A() {}

bool foo;

void bar() {

if(foo)

std::cout  Foo\n;

}

};



int main () {

A a;

a.bar();

return 0;

}



The uninitialized variable is detected only with -O1. It is vaguely documented

but that behavior seems quite odd and unexpected when you are not aware of it.


[Bug c/56523] -Wunitialized is described to be enabled by -Wall

2013-03-04 Thread paolo.carlini at oracle dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56523



Paolo Carlini paolo.carlini at oracle dot com changed:



   What|Removed |Added



 Status|UNCONFIRMED |RESOLVED

 Resolution||WORKSFORME



--- Comment #3 from Paolo Carlini paolo.carlini at oracle dot com 2013-03-04 
17:43:18 UTC ---

That some warnings are only emitted when optimizing is well known, and

discussed in many places.