[Bug c++/89192] -Wuninitialized doesn't warn about a vector initialization with uninitialized field
rguenth at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Feb 4 14:47:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89192
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Blocks| |24639
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
It works with optimization:
> g++-8 t.C -Wuninitialized -Wmaybe-uninitialized -O
t.C: In function ‘int main()’:
t.C:7:34: warning: ‘m.MyStruct::b’ is used uninitialized in this function
[-Wuninitialized]
MyStruct(unsigned arg1): vec(b), b(arg1){}
^
the reason is that at -O0 all calls such as the constructor are left in place
and thus the uninitialized use is not exposed to function-local analysis.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24639
[Bug 24639] [meta-bug] bug to track all Wuninitialized issues
More information about the Gcc-bugs
mailing list