Bug 42000 - missing -Wuninitialized warning on a user-defined class ctor
missing -Wuninitialized warning on a user-defined class ctor
Status: UNCONFIRMED
Product: gcc
Classification: Unclassified
Component: c++
4.4.1
: P3 normal
: ---
Assigned To: Not yet assigned to anyone
:
Depends on:
Blocks: Wuninitialized
  Show dependency treegraph
 
Reported: 2009-11-10 23:36 UTC by Martin Sebor
Modified: 2009-12-30 05:07 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Sebor 2009-11-10 23:36:19 UTC
gcc misses the access to the uninitialized member S::i in the program below
and fails to issue a warning for it.

I would expect to see a warning not only for the access to the member but
also for the definition of the user-defined constructor that fails to
initialize the data member.

$ cat t.cpp && gcc -Wuninitialized -Wall -Wextra -W -c t.cpp
int main () {
    struct S {
        int i;
        S() { }
    } s;

    return s.i;
}
Comment 1 Jonathan Wakely 2009-11-11 11:50:05 UTC
It would certainly be nice to get warnings about members that are not initialized in the constructor, I don't think GCC currently does that anywhere.

If you add -O then you will get a warning for the use of the member.  It's unfortunate that this warning is missed without optimisation, but -Wuninitialized no longer warns if you use it without -O
Comment 2 Manuel López-Ibáñez 2009-11-19 12:28:46 UTC
I think this is a duplicate of either bug 2972 or bug 19808 or one of the SRA testcases.