Open
Description
Hello.
We were reported a bug: microsoft/STL#2466
But we think that the report is wrong.
#include <exception>
#include <string>
using namespace std;
class C {
public:
C() = default;
C(const C&) = delete;
C& operator=(const C&) = delete;
C(C&&) = default;
C& operator=(C&&) = default;
private:
string m;
};
int main() {
exception_ptr eptr;
try {
throw C();
} catch (const C&) {
eptr = std::current_exception();
}
try {
rethrow_exception(eptr);
} catch (const C&) {
}
}
https://godbolt.org/z/q3cYGfneP
We think that the compiler should reject the program because the program violates [except.throw]/5: https://eel.is/c++draft/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
We decided to notify developers of other C++ compilers too.