[multi_index] GCC optimization warns about uninitialized variables

Hello.
I have a multi_index container that stores (and owns) pointers. It has 4
indexes that order themselves on member functions.
I get error-free and warning-free compiles as long as optimization is turned
off (-O0). I get the warning below at all levels of optimization (1 through
3).
I've stripped the code down to just what seems to be generating the error.
--- BEGIN test.cpp ---
#include <iostream>
#include <typeinfo>
#include <map>
#include
NodeMultiIndex;
int main() {
NodeMultiIndex c;
NodeMultiIndex::nth_index<0>::type& index = c.get<0>();
index.push_back(new NodeBase());
std::cout << *index.begin() << std::endl;
return 0;
}
--- END test.cpp ---
Compiling with G++ 4.1.1 with full optimizations and full warnings:
g++-4.1.1 -I../eclipselibs/boost -O3 -Wall -c -fmessage-length=0 test.cpp
../eclipselibs/boost/boost/multi_index/ordered_index.hpp: In member function
'boost::multi_index::detail::ordered_index_node<typename
SuperMeta::type::node_type>*
boost::multi_index::detail::ordered_index

Hello,
cp now
Hello.I have a multi_index container that stores (and owns) pointers. It has 4 indexes that order themselves on member functions.I get error-freeand warning-free compiles as long as optimization is turned off (-O0). I get the warning below at all levels of optimization (1 through 3).
[...]
Compiling with G++ 4.1.1 with full optimizations and full warnings: g++-4.1.1 -I../eclipselibs/boost -O3 -Wall -c -fmessage-length=0 test.cpp../eclipselibs/boost/boost/multi_index/ordered_index.hpp: In member function 'boost::multi_index::detail::ordered_index_node <typename SuperMeta::type::node_type>* boost::multi_index::detail::ordered_index
::insert_(...)[...] ../eclipselibs/boost/boost/multi_index/ordered_index.hpp:551: warning: 'inf$side' may be used uninitialized in this function
Thanks for reporting this problem. You might like to know that this is already fixed in the trunk and in the upcoming Boost 1.35 version: http://svn.boost.org/trac/boost/changeset/39922#file34 (look for "struct link_info") While you wait for the upgrage, I suggest you patch your local copy of Boost.MultiIndex in the same way as shown above, i.e. providing link_info with an explicit default ctor: struct link_info { link_info():side(to_left){} ordered_index_side side; node_impl_pointer pos; }; Hope this helps. Thank you for using Boost.MultiIndex, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
participants (2)
-
cp now
-
Joaquin M Lopez Munoz