Opened 6 years ago

Last modified 5 years ago

#12755 new Bugs

serialization/map.hpp tests for the wrong thing to figure out whether emplace_hint() exists

Reported by: bangerth@… Owned by: John Maddock
Milestone: To Be Determined Component: serialization
Version: Boost 1.63.0 Severity: Regression
Keywords: Cc: bangerth@…

Description

Originally from here: https://github.com/geodynamics/aspect/issues/1271

boost::serialization has this piece of code in serialization/map.hpp: `

typename Container::iterator result =

#ifdef BOOST_NO_CXX11_HDR_UNORDERED_MAP

s.insert(hint, t.reference());

#else

s.emplace_hint(hint, t.reference());

#endif

` The assumption must have been that BOOST_NO_CXX11_HDR_UNORDERED_MAP is indicative of whether std::map has an emplace_hint() function (which is new to C++11). The define comes from here (boost/config/stdlib/libstdcpp3.hpp): ` C++0x headers in GCC 4.3.0 and later

#if (BOOST_LIBSTDCXX_VERSION < 40300)
!defined(BOOST_LIBSTDCXX11)

# define BOOST_NO_CXX11_HDR_ARRAY # define BOOST_NO_CXX11_HDR_TUPLE # define BOOST_NO_CXX11_HDR_UNORDERED_MAP # define BOOST_NO_CXX11_HDR_UNORDERED_SET # define BOOST_NO_CXX11_HDR_FUNCTIONAL #endif ` The problem is that for GCC 4.8, BOOST_NO_CXX11_HDR_UNORDERED_MAP is not set, but the libstdc++ that comes with this compiler still doesn't have emplace_hint(). In other words, if one tries to compile something with GCC 4.8 that calls this function, then it will result in a compiler error.

The solution is to either exclude the "special" GCC 4.8 in this one location and fall back to insert(), or to have some kind of test that is actually specific to testing whether or not emplace_hint() exists.

Change History (2)

comment:1 by anonymous, 6 years ago

I should correct: the issue is with compilers *before* 4.8. Specifically, we have seen this with gcc 4.7.

comment:2 by Robert Ramey, 5 years ago

Owner: changed from Robert Ramey to John Maddock

Hmmm - I'm wondering if this shouldn't really be a correction in boost/config.hpp

Note: See TracTickets for help on using tickets.