/* Spurious "might be used uninitialized" warning in STL use. The following short program produces a spurious warning. The quoted function in stl_uninitialized.h is template<typename _InputIterator, typename _ForwardIterator> inline _ForwardIterator __uninitialized_copy_aux(_InputIterator __first, _InputIterator __last, _ForwardIterator __result, __false_type) { _ForwardIterator __cur = __result; // this is line 82 try { for ( ; __first != __last; ++__first, ++__cur) std::_Construct(&*__cur, *__first); return __cur; } catch(...) { std::_Destroy(__result, __cur); __throw_exception_again; } } We see this warning in other circumstances on several gcc versions, always in STL headers and usually in very simple statements of the form "sometype a = b;" where 'a' is reported a uninitialized (sic!). The sample given here compiles without warnings with -O1, but this is not generally the case. Any solutions or work-arounds? */ #include <iostream> #include <ostream> #include "boost/format.hpp" int main() { std::cout << boost::format("0x%04x ") % 42 << std::endl; } /* $ uname -a CYGWIN_NT-5.1 1.5.24(0.156/4/2) 2007-01-31 10:57 i686 Cygwin $ gcc --version gcc (GCC) 3.4.4 (cygming special, gdc 0.12, using dmd 0.125) $ g++ -ansi -Wall -O2 -I/cygdrive/d/Info/boost_1_32_0/ simpleformat.cpp /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_uninitialized.h: In member function `void std::vector<_Tp, _Alloc>::_M_fill_insert( __gnu_cxx::__normal_iterator<typename _Alloc::pointer, std::vector<_Tp, _Alloc> >, size_t, const _Tp&) [with _Tp = boost::io::detail::format_item<char, std::char_traits<char>, std::allocator<char> >, _Alloc = std::allocator<boost::io::detail::format_item<char, std::char_traits<char>, std::allocator<char> > >]': /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 */
Hi, could you attach a preprocessed testcase (*.i) generated by adding -save-temps ? The minimal the testcase, the better. Thanks.
maybe the same bug to 22207?
(In reply to comment #2) > maybe the same bug to 22207? yeah, probably the same as bug 22207, but that one is only fixed on 4.0.0 We need a fix on 3.x.x
Two years without testcase. I cannot reproduce. Probably a duplicate. Marked as INVALID. Please, reopen if you have a reproducible testcase obtained following http://gcc.gnu.org/bugs.html#report
Subject: Spurious 2 years without a test case? The very first post provides a test case. All boost users are affected by this bug. Bugzilla from gcc-bugzilla@gcc.gnu.org wrote: > > > > ------- Comment #4 from manu at gcc dot gnu dot org 2009-02-07 16:30 > ------- > Two years without testcase. I cannot reproduce. Probably a duplicate. > Marked as > INVALID. Please, reopen if you have a reproducible testcase obtained > following > http://gcc.gnu.org/bugs.html#report > > > -- > > manu at gcc dot gnu dot org changed: > > What |Removed |Added > ---------------------------------------------------------------------------- > Status|UNCONFIRMED |RESOLVED > Resolution| |INVALID > > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30680 > > > Quoted from: http://www.nabble.com/-Bug-c%2B%2B-30680---New%3A-Spurious-%22might-be-used-uninitialized%22-warning-in-STL-use.-tp8767948p21890122.html
Re. comment #5. Two years without a test case that allows us to reproduce the bug. REPRODUCE the bug. Is that too hard for you to understand? If we can't reproduce the bug, we can't diagnose the problem and fix the bug. The test case from comment #0 does not trigger this bug in post-4.0 compilers (at least, not for the ones I tried, and apparently likewise for Manu).