User account creation filtered due to spam.

Bug 30680 - Spurious "might be used uninitialized" warning in STL use.
Summary: Spurious "might be used uninitialized" warning in STL use.
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.4
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks: Wuninitialized
  Show dependency treegraph
 
Reported: 2007-02-02 14:32 UTC by Vic Hartog
Modified: 2009-03-08 18:08 UTC (History)
4 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vic Hartog 2007-02-02 14:32:36 UTC
/*
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
*/
Comment 1 Manuel López-Ibáñez 2007-08-21 09:00:57 UTC
Hi,
could you attach a preprocessed testcase (*.i) generated by adding -save-temps ?
The minimal the testcase, the better.
Thanks.
Comment 2 Jia-Shiun Li 2007-09-10 09:56:11 UTC
maybe the same bug to 22207?
Comment 3 pdemarco 2008-09-30 20:00:28 UTC
(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
Comment 4 Manuel López-Ibáñez 2009-02-07 16:30:15 UTC
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
Comment 5 dick.dunbar@gmail.com 2009-03-08 17:59:35 UTC
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

Comment 6 Steven Bosscher 2009-03-08 18:08:13 UTC
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).