@@ -1481,7 +1481,9 @@ namespace __variant
|| !is_nothrow_move_constructible_v<_Tj>)
this->emplace<__index>(std::forward<_Tp>(__rhs));
else
- operator=(variant(std::forward<_Tp>(__rhs)));
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 3585. converting assignment with immovable alternative
+ this->emplace<__index>(_Tj(std::forward<_Tp>(__rhs)));
}
return *this;
}
new file mode 100644
@@ -0,0 +1,16 @@
+// { dg-do compile { target c++17 } }
+
+// LWG 3585. Variant converting assignment with immovable alternative
+
+#include <variant>
+#include <string>
+
+struct A {
+ A() = default;
+ A(A&&) = delete;
+};
+
+int main() {
+ std::variant<A, std::string> v;
+ v = "hello";
+}