https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103879
Bug ID: 103879
Summary: error: accessing value of variant::_Copy_ctor_base
through a 'const variant<string>' glvalue in a
constant expression
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: hewillk at gmail dot com
Target Milestone: ---
From
https://stackoverflow.com/questions/70541636/stdvariant-of-stdstring-inside-any-class-in-constexpr-context-fails-to-compi
#include <string>
#include <variant>
struct S {
std::variant<std::string> v;
};
constexpr int func() {
S s{"str"};
return 0;
}
constexpr int x = func();
I think this should be well-formed.