https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90165
Bug ID: 90165 Summary: std::variant constructs wrong alternative Product: gcc Version: 8.3.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- #include <variant> #include <stdio.h> struct none { none() = delete; }; struct any { template <typename T> any(T&&) {} }; int main() { std::variant<none, any> v(std::in_place_type<none>); std::variant<none, any> v2(std::in_place_index<0>); printf("constructed alternatives %zu and %zu\n", v.index(), v2.index()); } This program should be ill-formed, but instead compiles and outputs: constructed alternatives 1 and 1