public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/32395]  New: false positive warning about use of uninitialized variable.
@ 2007-06-18 17:24 pluto at agmk dot net
  2007-06-18 17:25 ` [Bug c++/32395] " pluto at agmk dot net
                   ` (17 more replies)
  0 siblings, 18 replies; 19+ messages in thread
From: pluto at agmk dot net @ 2007-06-18 17:24 UTC (permalink / raw)
  To: gcc-bugs

gcc-4.1 produces a warning for the following testcase.
(testcase uses headers from boost-1.34.0).

$ cat multi_index_test.cpp

#include <boost/multi_index_container.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/identity.hpp>
#include <boost/multi_index/member.hpp>
#include <vector>

using namespace boost;
using namespace boost::multi_index;

struct X
{
        int value;
        bool operator < ( X const& e) const;
};

typedef multi_index_container
<
        X,
        indexed_by
        <
                ordered_unique< identity< X > >,
                ordered_non_unique< member< X, int, &X::value > >
        >
> C;

extern
C f( std::vector< X > const& v )
{
        return C( v.begin(), v.end() );
}


$ x86_64-gnu-linux-g++ \
  -I/local/devel/buildenv41/x86_64-gnu-linux/boost-stdc++-1.34.0/include \
  multi_index_test.cpp -O1 -Wall --save-temps -c

/local/devel/buildenv41/x86_64-gnu-linux/boost-stdc++-1.34.0/include/boost/multi_index/ordered_index.hpp:
In member function 'std::pair<typename
boost::multi_index::detail::multi_index_base_type<Value, IndexSpecifierList,
Allocator>::type::node_type*, bool>
boost::multi_index::multi_index_container<Value, IndexSpecifierList,
Allocator>::insert_(const Value&, typename
boost::multi_index::detail::multi_index_base_type<Value, IndexSpecifierList,
Allocator>::type::node_type*) [with Value = X, IndexSpecifierList =
boost::multi_index::indexed_by<boost::multi_index::ordered_unique<boost::multi_index::identity<X>,
mpl_::na, mpl_::na>,
boost::multi_index::ordered_non_unique<boost::multi_index::member<X, int,
&X::value>, mpl_::na, mpl_::na>, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, Allocator =
std::allocator<X>]':
/local/devel/buildenv41/x86_64-gnu-linux/boost-stdc++-1.34.0/include/boost/multi_index/ordered_index.hpp:566:
warning:
'inf.boost::multi_index::detail::ordered_index<boost::multi_index::identity<X>,
std::less<X>, boost::multi_index::detail::nth_layer<1, X,
boost::multi_index::indexed_by<boost::multi_index::ordered_unique<boost::multi_index::identity<X>,
mpl_::na, mpl_::na>,
boost::multi_index::ordered_non_unique<boost::multi_index::member<X, int,
&X::value>, mpl_::na, mpl_::na>, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, std::allocator<X>
>, boost::mpl::vector0<mpl_::na>,
boost::multi_index::detail::ordered_unique_tag>::link_info::side' may be used
uninitialized in this function

as far i can the warning comes from:

bool link_point(key_param_type k,link_info& inf,ordered_unique_tag)
  {
    (...)
    else{
      inf.pos=yy->impl();  <== partial initialziation of link_info&.
      return false;
    }
  }

in fact, all use cases of link_point use only inf.pos
when {hinted_,}link_point returns false.

(...)

  if(!link_point(key(v),inf,Category())){
      return node_type::from_impl(inf.pos);

(...)

  node_type* insert_(value_param_type v,node_type* position,node_type* x)
  {
    link_info inf;
    if(!hinted_link_point(key(v),position,inf,Category())){
      return node_type::from_impl(inf.pos);

(...)

gcc-3.4.5 and 4.2 works fine (no warning), but 4.1.2 fails.
4.0 and 4.3 wasn't tested.


-- 
           Summary: false positive warning about use of uninitialized
                    variable.
           Product: gcc
           Version: 4.1.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pluto at agmk dot net


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32395


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2010-03-15 13:40 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-18 17:24 [Bug c++/32395] New: false positive warning about use of uninitialized variable pluto at agmk dot net
2007-06-18 17:25 ` [Bug c++/32395] " pluto at agmk dot net
2007-06-19  8:10 ` [Bug middle-end/32395] " pinskia at gcc dot gnu dot org
2007-06-24 15:54 ` pluto at agmk dot net
2007-06-25 22:56 ` pluto at agmk dot net
2007-06-25 22:57 ` pluto at agmk dot net
2007-08-22 15:44 ` manu at gcc dot gnu dot org
2007-08-22 15:54 ` pluto at agmk dot net
2007-08-22 16:48 ` manu at gcc dot gnu dot org
2007-08-22 18:36 ` pluto at agmk dot net
2007-09-25 14:24 ` pluto at agmk dot net
2007-09-27  0:58 ` manu at gcc dot gnu dot org
2007-09-27  4:07 ` bangerth at dealii dot org
2008-01-08 20:00 ` pluto at agmk dot net
2008-01-23 21:25 ` pluto at agmk dot net
2008-01-23 23:20 ` manu at gcc dot gnu dot org
2008-02-01 17:56 ` manu at gcc dot gnu dot org
2010-03-15 10:32 ` [Bug middle-end/32395] false uninitialized warning (huge testcase) pluto at agmk dot net
2010-03-15 13:40 ` manu at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).