From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5734 invoked by alias); 27 Jun 2005 23:08:24 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 5719 invoked by uid 48); 27 Jun 2005 23:08:19 -0000 Date: Mon, 27 Jun 2005 23:08:00 -0000 From: "brian at dessent dot net" To: gcc-bugs@gcc.gnu.org Message-ID: <20050627230816.22207.brian@dessent.net> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug libstdc++/22207] New: Spurious 'might be used uninitialized' warnings in STL headers with -O2 X-Bugzilla-Reason: CC X-SW-Source: 2005-06/txt/msg03295.txt.bz2 List-Id: The following reduced test case causes spurious -Wuninitialized warnings, but only with -O2: ----- #include #include class OptionSet { public: OptionSet (); std::vector const &nonOptions() const; private: std::vector nonoptions; }; OptionSet::OptionSet() { nonoptions = std::vector (); } std::vector const & OptionSet::nonOptions() const { return nonoptions; } ----- $ g++ -Wuninitialized -O2 -c spurious_uninitialized_testcase.cc /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::string, _Alloc = std::allocator]': /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 $ g++ -v 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) ----- The warnings only occur at -O2 and seem to have something to do with inlining. This causes our build that uses "-Wall -Werror" to die whereas it had no problem with this warning in gcc-3.3. I'm sensitive to the fact that it's impossible for the compiler to get this warning correct every time, and the reason for the use of "might be" in the warning text. It's acceptible to emit warnings about things that may not actually be the case, and normally I would just modify the build environment to disable that warning or lose -Werror. But in this case, the code in question is in the STL and is completely out of the hands of the user, and I don't think it's unreasonable to expect to be able to compile STL-based code with -Werror -Wall. -- Summary: Spurious 'might be used uninitialized' warnings in STL headers with -O2 Product: gcc Version: 3.4.4 Status: UNCONFIRMED Severity: normal Priority: P2 Component: libstdc++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: brian at dessent dot net CC: gcc-bugs at gcc dot gnu dot org GCC host triplet: i686-pc-cygwin http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22207