Date: Fri, 02 Sep 2022 07:51:47 +0800
Hi,
GCC and clang at the moment allow throwing of noncopyable prvalue expressions:
struct foo
{
foo() = default;
foo(foo const&) = delete;
foo(foo&&) = delete;
};
void bar()
{
throw foo();
}
https://compiler-explorer.com/z/d7h8f8ror
I was wondering if that's intended, since I can't quite relate it to the wording of except.throw#5:
> When the thrown object is a class object, the constructor selected for the copy-initialization as well as the constructor selected for a copy-initialization considering the thrown object as an lvalue shall be non-deleted and accessible, even if the copy/move operation is elided ([class.copy.elision]).
As far as I understand, mandatory copy elision means that the constructor selected for copy-initialization in this case is the _default constructor_. Copy-initialization doesn't even consider copy/move constructors here. The part about "the thrown object as an lvalue" doesn't make sense to me in this context.
Anyway, was this change intended? Should the example above compile?
Thanks,
Robert
--
Std-Discussion mailing list
Std-Discussion_at_[hidden]
https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion
Received on 2022-09-01 23:52:01