https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102913
Bug ID: 102913 Summary: variant_construct_single should not remove the const qualifier of Up 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/69696170: variant#L568: template<typename _Tp, typename _Up> _GLIBCXX20_CONSTEXPR void __variant_construct_single(_Tp&& __lhs, _Up&& __rhs_mem) { using _Type = __remove_cvref_t<_Up>; This should be using _Type = remove_reference_t<_Up>. #include <string> #include <variant> int main() { using var_t = std::variant<const int, const std::string>; var_t v; var_t v2(v); } https://godbolt.org/z/zaov3GxdY