[Bug libstdc++/95832] std::vector<bool> specialization leading std::variant ctor treating it as int rather than bool
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Jun 23 15:36:35 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95832
--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
No, that doesn't work for things convertible to pointers.
#include <variant>
struct P { operator void*() const; };
std::variant<bool> v{ P{} };
The argument type here is not a pointer, so your suggestion would construct the
bool, which is exactly the case P0602 was designed to prevent.
"Can be converted to bool via conversion to a pointer or function pointer type"
is not practical to detect, and I have no intention of trying. See Bug 93628
for a related problem.
More information about the Gcc-bugs
mailing list