Bug 36866 - lack of warning when initializing a class member from an uninitialized variable
Summary: lack of warning when initializing a class member from an uninitialized variable
Status: RESOLVED DUPLICATE of bug 19808
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.1.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-17 19:15 UTC by Imre Pentek
Modified: 2008-07-21 14:30 UTC (History)
6 users (show)

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


Attachments
any.cpp (129 bytes, text/plain)
2008-07-17 19:16 UTC, Imre Pentek
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Imre Pentek 2008-07-17 19:15:04 UTC
Hello, the attached code compiles without any warning when compiled with the command
g++ -W -Wall any.cpp -c -o any.o
but x gets initialised from itself, actually dereferencing x prior to initializing it. At this point it is trivial that x wasn't initialised.




Using built-in specs.
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-4.1.2/work/gcc-4.1.2/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.1.2 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.1.2 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.1.2/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.1.2/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --enable-secureplt --enable-multilib --enable-libmudflap --disable-libssp --enable-java-awt=gtk --enable-languages=c,c++,java,treelang,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
Thread model: posix
gcc version 4.1.2 (Gentoo 4.1.2 p1.1)
Comment 1 Imre Pentek 2008-07-17 19:16:12 UTC
Created attachment 15925 [details]
any.cpp
Comment 2 Manuel López-Ibáñez 2008-07-21 14:30:57 UTC
To fix this testcase we would need to fix a few of the -Wuninitialized issues, since -Wuninitialized does not work without optimisation, we don't handle VOPs (no -Wunitialized for pointers then), and -Winit-self is broken for some cases. Nonetheless, fixing PR19808 would be a start.

*** This bug has been marked as a duplicate of 19808 ***