User account creation filtered due to spam.

Bug 42000

Summary: missing -Wuninitialized warning on a user-defined class ctor
Product: gcc Reporter: Martin Sebor <msebor>
Component: c++Assignee: Not yet assigned to anyone <unassigned>
Status: UNCONFIRMED ---    
Severity: normal CC: fang, gcc-bugs, manu
Priority: P3    
Version: 4.4.1   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed:
Bug Depends on:    
Bug Blocks: 24639    

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.