Opened 7 years ago
Closed 5 years ago
#11875 closed Bugs (fixed)
Boost.Phoenix should not forward-declare std::unordered_set / map
Reported by: | Owned by: | Thomas Heller | |
---|---|---|---|
Milestone: | Boost 1.65.0 | Component: | phoenix |
Version: | Boost 1.64.0 | Severity: | Problem |
Keywords: | Cc: | braden@… |
Description
Boost 1.60 introduced the header boost/phoenix/stl/algorithm/detail/std_unordered_set_or_map_fwd.hpp.
When building on Linux with libstdc++ debug mode (-DGLIBCXX_DEBUG) this causes ambiguous references to the forward-declared classes because in libstdc++ side, they now live in the std::debug namespace instead.
The following test cases triggers it :
#include <boost/spirit/include/phoenix.hpp> #include <unordered_map> void f() { std::unordered_map<int, float> map; }
when built with
g++ -std=c++11 -D_GLIBCXX_DEBUG=1 -c problem.cpp
Change History (5)
comment:1 by , 7 years ago
Cc: | added |
---|
comment:2 by , 7 years ago
Got another similar problem (in boost 1.60) in boost/phoenix/stl/algorithm/detail/is_unordered_set_or_map.hpp
.
The BOOST_PHOENIX_USING_LIBCPP trick seems to work however.
comment:3 by , 6 years ago
Milestone: | To Be Determined → Boost 1.62.0 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
This should be fixed in 1.62 release (https://github.com/boostorg/phoenix/pull/33).
comment:4 by , 5 years ago
Milestone: | Boost 1.62.0 → Boost 1.65.0 |
---|---|
Resolution: | fixed |
Status: | closed → reopened |
Version: | Boost 1.60.0 → Boost 1.64.0 |
This is still wrong. There is no legal way to forward declare std::unordered_set/std::unordered_map. According to the standard ([namespace.std]), these forward declarations have undefined behavior.
This need to change to
#include <unordered_map> #include <unordered_set>
comment:5 by , 5 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
OK, fwd-decl will be replaced with include by https://github.com/boostorg/phoenix/pull/54.
There are other problems with this, as well, using gcc/libstdc++ (4.9, at least). For instance, this template specialization fails to compile if the problem Phoenix header gets included:
For the time being, I'm simply compiling my code with
BOOST_PHOENIX_USING_LIBCPP
defined, as this disables the forward declarations. But this is obviously undesirable if that macro ever gets used for something that is actually libc++-specific.