[Bug libstdc++/95832] New: std::vector<bool> specialization leading std::variant ctor treating it as int rather than bool
fiesh at zefix dot tv
gcc-bugzilla@gcc.gnu.org
Tue Jun 23 04:48:39 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95832
Bug ID: 95832
Summary: std::vector<bool> specialization leading std::variant
ctor treating it as int rather than bool
Product: gcc
Version: 10.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: fiesh at zefix dot tv
Target Milestone: ---
The following code returned 1 when compiled with gcc-9 but returns 0 with
gcc-10. Since clang exhibits the exact same behavior depending on the
installed gcc version, I suppose it might be because of libstdc++.
It's worth noting that MSVC on godbolt also returns 0.
My primitive reading skills suggest to me that
http://eel.is/c++draft/variant#ctor-14 says it should be 1. (Overload
resolution works correctly in that it prefers an f(bool) over an f(int) when
passed b.back().)
#include <vector>
#include <variant>
using T = std::variant<int, bool>;
int main()
{
std::vector<bool> b{false};
std::vector<T> ts;
ts.emplace_back(b.back());
return ts.back().index();
}
More information about the Gcc-bugs
mailing list