This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/32395] New: false positive warning about use of uninitialized variable.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]