diff --git a/libcxx/include/optional b/libcxx/include/optional index 2fad11ce419e..a147d69da00f 100644 --- a/libcxx/include/optional +++ b/libcxx/include/optional @@ -773,7 +773,7 @@ public: _And< _IsNotSame<__uncvref_t<_Up>, optional>, _Or< - _IsNotSame<_Up, value_type>, + _IsNotSame<__uncvref_t<_Up>, value_type>, _Not> >, is_constructible, diff --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.assign/assign_value.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.assign/assign_value.pass.cpp index 8d2a8a00c943..3dd28ace26fd 100644 --- a/libcxx/test/std/utilities/optional/optional.object/optional.object.assign/assign_value.pass.cpp +++ b/libcxx/test/std/utilities/optional/optional.object/optional.object.assign/assign_value.pass.cpp @@ -241,6 +241,16 @@ enum MyEnum { Zero, One, Two, Three, FortyTwo = 42 }; using Fn = void(*)(); +// https://bugs.llvm.org/show_bug.cgi?id=38638 +template +constexpr T pr38638(T v) +{ + std::optional o; + o = v; + return *o + 2; +} + + int main(int, char**) { test_sfinae(); @@ -269,5 +279,7 @@ int main(int, char**) } test_throws(); + static_assert(pr38638(3) == 5, ""); + return 0; }