[go: nahoru, domu]

Bug 23648 - Spurious uninitialized variable warnings at -O1 and higher
Summary: Spurious uninitialized variable warnings at -O1 and higher
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.4.4
: P2 normal
Target Milestone: 4.2.0
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks: Wuninitialized
  Show dependency treegraph
 
Reported: 2005-08-31 07:06 UTC by Tim Starling
Modified: 2005-11-26 07:47 UTC (History)
2 users (show)

See Also:
Host: i686-pc-cygwin
Target: i686-pc-cygwin
Build: i686-pc-cygwin
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Preprocessed test case (34.01 KB, text/plain)
2005-08-31 07:08 UTC, Tim Starling
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Starling 2005-08-31 07:06:20 UTC
The compiler issues spurious warnings such as "warning: '__cur' might be used
uninitialized in this function", where on the corresponding line, __cur is the
lvalue in an assignment. The warnings are not issued at -O0. I noticed this
problem when dealing with nested STL containers. 

This is not a duplicate of bug 5035.

Here is the test code: 

#include <vector>
#include <set>

int main(int, char**)
{
	std::vector<std::vector<std::set<int> > > basis;
	basis.clear();	
	return 0;
}

I'll attach the preprocessed output. Command line and compiler output follows:

% g++ -v -save-temps -Wall -o uninitialized -O2 uninitialized.cc 
Reading specs from /usr/lib/gcc/i686-pc-cygwin/3.4.4/specs
Configured with: /gcc/gcc-3.4.4/gcc-3.4.4-1/configure --verbose --prefix=/usr
--exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --libexecdir=/usr/lib
--mandir=/usr/share/man --infodir=/usr/share/info
--enable-languages=c,ada,c++,d,f77,java,objc --enable-nls
--without-included-gettext --enable-version-specific-runtime-libs --without-x
--enable-libgcj --disable-java-awt --with-system-zlib --enable-interpreter
--disable-libgcj-debug --enable-threads=posix --enable-java-gc=boehm
--disable-win32-registry --enable-sjlj-exceptions --enable-hash-synchronization
--enable-libstdcxx-debug : (reconfigured) 
Thread model: posix
gcc version 3.4.4 (cygming special) (gdc 0.12, using dmd 0.125)
 /usr/lib/gcc/i686-pc-cygwin/3.4.4/cc1plus.exe -E -quiet -v -D__CYGWIN32__
-D__CYGWIN__ -Dunix -D__unix__ -D__unix -idirafter
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../include/w32api -idirafter
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/lib/../../include/w32api
uninitialized.cc -mtune=pentiumpro -Wall -O2 -o uninitialized.ii
ignoring nonexistent directory
"/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/include"
ignoring duplicate directory
"/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/lib/../../include/w32api"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++
 /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/i686-pc-cygwin
 /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/backward
 /usr/local/include
 /usr/lib/gcc/i686-pc-cygwin/3.4.4/include
 /usr/include
 /usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../include/w32api
End of search list.
 /usr/lib/gcc/i686-pc-cygwin/3.4.4/cc1plus.exe -fpreprocessed uninitialized.ii
-quiet -dumpbase uninitialized.cc -mtune=pentiumpro -auxbase uninitialized -O2
-Wall -version -o uninitialized.s
GNU C++ version 3.4.4 (cygming special) (gdc 0.12, using dmd 0.125) (i686-pc-cygwin)
        compiled by GNU C version 3.4.4 (cygming special) (gdc 0.12, using dmd
0.125).
GGC heuristics: --param ggc-min-expand=47 --param ggc-min-heapsize=32702
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_vector.h: In member
function `std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const
std::vector<_Tp, _Alloc>&) [with _Tp = std::set<int, std::less<int>,
std::allocator<int> >, _Alloc = std::allocator<std::set<int, std::less<int>,
std::allocator<int> > >]':
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_vector.h:715: warning:
'__result' might be used uninitialized in this function
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_uninitialized.h:82:
warning: '__cur' might be used uninitialized in this function
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_uninitialized.h:82:
warning: '__cur' might be used uninitialized in this function
 /usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/as.exe -o
uninitialized.o uninitialized.s
 /usr/lib/gcc/i686-pc-cygwin/3.4.4/collect2.exe -Bdynamic
--dll-search-prefix=cyg -o uninitialized.exe
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../crt0.o
-L/usr/lib/gcc/i686-pc-cygwin/3.4.4 -L/usr/lib/gcc/i686-pc-cygwin/3.4.4
-L/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../.. uninitialized.o -lstdc++ -lgcc
-lcygwin -luser32 -lkernel32 -ladvapi32 -lshell32 -lgcc
Comment 1 Tim Starling 2005-08-31 07:08:30 UTC
Created attachment 9629 [details]
Preprocessed test case
Comment 2 Gabriel Dos Reis 2005-11-26 07:47:56 UTC
With mailine compiler (GCC-4.2.x), I cannot reproduce the reported behaviour.

-- Gaby