Wrong constraint for std::optional<T>::operator=(U&&) #37986
Labels
bugzilla
Issues migrated from bugzilla
compile-fail
Use [accepts-invalid] and [rejects-valid] instead
libc++
libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Extended Description
The following should compile:
#include
constexpr int foo(int i) {
std::optional o;
o = i;
return *o;
}
Wandbox tells me:
prog.cc:2:15: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
constexpr int foo(int i) {
^
prog.cc:4:5: note: non-constexpr function 'operator=<int &, void>' cannot be used in a constant expression
o = i;
^
/opt/wandbox/clang-6.0.0/include/c++/v1/optional:773:5: note: declared here
operator=(_Up&& __v)
^
https://wandbox.org/permlink/OrXOqTuQHDSddHod
The note shows that operator=(U&&) is being used, but that should not participate in overload resolution unless conjunction_v<is_scalar, is_same<T, decay_t>> is false.
In my code is_scalar is true, and is_same<int, decay_t<int&>> is true.
The text was updated successfully, but these errors were encountered: