(I looked for duplicate -Wuninitialized bugs but didn't see anything similar)
In the attached minimized testcase I get a clear 'is used uninitialized'
warning downgraded to a 'may be used uninitialized' warning on unrelated code
changes.
The program compiles correctly with the following flags: -O3 -Wall
To move one function definition into a namespace, add -DBAD_NAMESPACE and get
the wrong warning.
Reordering/removing/adding/changing the sizes of local variables makes the
warning restore to 'is used uninitialized', one example can be enabled by
-DGOOD_ORDER
This is a regression since 4.3 as 4.2 always gives a 'is used uninitialized'
warning. I tested with the following compilers from SVN on amd64 and x86
architectures:
g++-trunk (GCC) 4.6.0 20100901 (experimental) ==> BAD
g++-4.5.x (GCC) 4.5.2 20100901 (prerelease) ==> BAD
g++-4.4.x (GCC) 4.4.5 20100824 (prerelease) ==> BAD
g++-4.3.x (GCC) 4.3.6 20100824 (prerelease) ==> BAD
g++-4.2.x (GCC) 4.2.5 20090330 (prerelease) ==> OK
+ g++-4.5.x -std=c++0x -O3 -Wall -c PRmbuuitf.cpp
PRmbuuitf.cpp: In function 'void test()':
PRmbuuitf.cpp:66:25: warning: 'b$t$MBUUITF' is used uninitialized in this
function
PRmbuuitf.cpp:64:5: note: 'b$t$MBUUITF' was declared here
+ g++-4.5.x -std=c++0x -O3 -Wall -c PRmbuuitf.cpp -DBAD_NAMESPACE
PRmbuuitf.cpp: In function 'void test()':
vvv
PRmbuuitf.cpp:66:25: warning: 'b$t$MBUUITF' may be used uninitialized in this
function
^^^
PRmbuuitf.cpp:64:5: note: 'b$t$MBUUITF' was declared here
+ g++-4.5.x -std=c++0x -O3 -Wall -c PRmbuuitf.cpp -DBAD_NAMESPACE -DGOOD_ORDER
PRmbuuitf.cpp: In function 'void test()':
PRmbuuitf.cpp:66:25: warning: 'b$t$MBUUITF' is used uninitialized in this
function
PRmbuuitf.cpp:64:5: note: 'b$t$MBUUITF' was declared here
+ g++-4.2.x -O3 -Wall -c PRmbuuitf.cpp -DBAD_NAMESPACE
PRmbuuitf.cpp: In function 'void test()':
PRmbuuitf.cpp:66: warning: 'b.B::t.T::MBUUITF' is used uninitialized in this
function
PRmbuuitf.cpp:64: note: 'b.B::t.T::MBUUITF' was declared here
--
Summary: 'is used uninitialized' becomes 'may be used
uninitialized' on unrelated code changes (namespace
addition)
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: gcc at abeckmann dot de
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45609