Consider a struct A with copy-constructor deleted but having instead the constructor from not-const reference. Can one throw an object of A and then catch it by value as in the example program:
struct A {
A() {}
A(A&) {}
A(const A&) = delete;
};
int main() {
try {
throw A{};
}
catch( A ) {
}
}
Both GCC and Clang allow such usage. Although MSVC prints an error:
C2316: 'A': cannot be caught as the destructor and/or copy constructor are inaccessible or deleted
Demo: https://gcc.godbolt.org/z/P4c6Ea9fz
Indeed A(const A&) is deleted but A(A&) is accessible here. Is it a wrong diagnostics from MSVC?