-
Notifications
You must be signed in to change notification settings - Fork 16.5k
Closed
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillacompile-failUse [accepts-invalid] and [rejects-valid] insteadUse [accepts-invalid] and [rejects-valid] insteadlibc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Description
| Bugzilla Link | 38638 |
| Resolution | FIXED |
| Resolved on | Jun 27, 2019 11:41 |
| Version | 6.0 |
| OS | All |
| CC | @dwblaikie,@mclow |
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillacompile-failUse [accepts-invalid] and [rejects-valid] insteadUse [accepts-invalid] and [rejects-valid] insteadlibc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.