[llvm-bugs] [Bug 44723] New: Defaulted comparisons deleted for class containing class containing class template with user-provided operator<=> with deduced return type
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Jan 30 22:40:48 PST 2020
https://bugs.llvm.org/show_bug.cgi?id=44723
Bug ID: 44723
Summary: Defaulted comparisons deleted for class containing
class containing class template with user-provided
operator<=> with deduced return type
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++2a
Assignee: unassignedclangbugs at nondot.org
Reporter: david at doublewise.net
CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk
The following valid code:
```
#include <compare>
template<int>
struct a {
friend constexpr auto operator<=>(a const & lhs, a const & rhs) {
return std::strong_ordering::equal;
}
};
struct b {
friend auto operator<=>(b const &, b const &) = default;
a<0> m_value;
};
struct c {
friend auto operator<=>(c const &, c const &) = default;
a<0> m_value;
};
auto x = c() <=> c();
```
is rejected with the message:
```
main.cpp:11:14: warning: explicitly defaulted three-way comparison operator is
implicitly deleted [-Wdefaulted-function-deleted]
friend auto operator<=>(b const &, b const &) = default;
^
main.cpp:12:7: note: return type of defaulted 'operator<=>' cannot be deduced
because return type 'auto' of three-way comparison for member 'm_value' is not
a standard comparison category type
a<0> m_value;
^
main.cpp:5:24: note: selected 'operator<=>' for member 'm_value' declared here
friend constexpr auto operator<=>(a const & lhs, a const & rhs) {
^
main.cpp:16:14: warning: explicitly defaulted three-way comparison operator is
implicitly deleted [-Wdefaulted-function-deleted]
friend auto operator<=>(c const &, c const &) = default;
^
main.cpp:17:7: note: return type of defaulted 'operator<=>' cannot be deduced
because return type 'auto' of three-way comparison for member 'm_value' is not
a standard comparison category type
a<0> m_value;
^
main.cpp:5:24: note: selected 'operator<=>' for member 'm_value' declared here
friend constexpr auto operator<=>(a const & lhs, a const & rhs) {
^
main.cpp:19:14: error: overload resolution selected deleted operator '<=>'
auto x = c() <=> c();
~~~ ^ ~~~
main.cpp:16:14: note: candidate function has been implicitly deleted
friend auto operator<=>(c const &, c const &) = default;
^
2 warnings and 1 error generated.
```
--
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/20200131/802fda97/attachment.html>
More information about the llvm-bugs
mailing list