Date: Fri, 02 Sep 2022 07:51:47 +0800
GCC and clang at the moment allow throwing of noncopyable prvalue expressions:
foo() = default;
foo(foo const&) = delete;
foo(foo&&) = delete;
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?
Std-Discussion mailing list
Received on 2022-09-01 23:52:01