[llvm-bugs] [Bug 38638] New: Wrong constraint for std::optional<T>::operator=(U&&)
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Aug 20 08:04:55 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=38638
Bug ID: 38638
Summary: Wrong constraint for std::optional<T>::operator=(U&&)
Product: libc++
Version: 6.0
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: All Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: zilla at kayari.org
CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com
The following should compile:
#include <optional>
constexpr int foo(int i) {
std::optional<int> 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<T>,
is_same<T, decay_t<U>>> is false.
In my code is_scalar<int> is true, and is_same<int, decay_t<int&>> is true.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180820/25d8f521/attachment.html>
More information about the llvm-bugs
mailing list