libstdc++-v3/ChangeLog:
PR libstdc++/100982
* include/std/optional (optional::operator=(const optional<U>&)):
Fix value category used in is_assignable check.
* testsuite/20_util/optional/assignment/100982.cc: New test.
template<typename _Up>
enable_if_t<__and_v<__not_<is_same<_Tp, _Up>>,
is_constructible<_Tp, const _Up&>,
- is_assignable<_Tp&, _Up>,
+ is_assignable<_Tp&, const _Up&>,
__not_<__converts_from_optional<_Tp, _Up>>,
__not_<__assigns_from_optional<_Tp, _Up>>>,
optional&>
--- /dev/null
+// { dg-do compile { target c++17 } }
+
+#include <optional>
+
+struct U {};
+
+struct T {
+ explicit T(const U&);
+ T& operator=(const U&);
+ T& operator=(U&&) = delete;
+};
+
+int main() {
+ std::optional<U> opt1;
+ std::optional<T> opt2;
+ opt2 = opt1; // PR libstdc++/100982
+}