[llvm-bugs] [Bug 40997] New: [coroutines] Clang should not consider use of co_await within a move/copy-assignment operator as ill-formed
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Mar 7 13:07:34 PST 2019
https://bugs.llvm.org/show_bug.cgi?id=40997
Bug ID: 40997
Summary: [coroutines] Clang should not consider use of co_await
within a move/copy-assignment operator as ill-formed
Product: clang
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: C++2a
Assignee: unassignedclangbugs at nondot.org
Reporter: lewissbaker at gmail.com
CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk
>From https://reviews.llvm.org/D59076?id=189653#inline-522719
Clang currently raises an error if any special member function is compiled as a
coroutine. This includes constructors, destructors as well as copy/move
assignment operators.
However, N4775 only seems to have wording to disallow constructors/destructors
from being coroutines. With wording added to [class.ctor] and [class.dtor] but
no wording is added to [class.copy.assign] to disallow it from being a
coroutine.
See https://godbolt.org/z/cdhH3l
#include <experimental/coroutine>
using namespace std::experimental;
struct task {
struct promise_type {
suspend_never initial_suspend();
suspend_never final_suspend();
task get_return_object();
void return_void();
void unhandled_exception();
};
};
struct X {
task operator=(const X& other) {
co_return; // ERROR: 'co_return' cannot be used in a copy assignment
operator
}
task operator=(X& other) {
co_return; // ERROR: 'co_return' cannot be used in a copy assignment
operator
}
task operator=(X&& other) {
co_return; // ERROR: 'co_return' cannot be used in a move assignment
operator
}
task operator=(const X&& other) {
co_return; // ERROR: 'co_return' cannot be used in a move assignment
operator
}
task operator=(int x) {
co_return; // OK
}
};
All 5 of these should be accepted according to wording of N4775.
--
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/20190307/c143887c/attachment.html>
More information about the llvm-bugs
mailing list