// https://godbolt.org/z/W9P6GrG4x #include <stdio.h> int main() { try { throw nullptr; } catch (const int(&)[2]) { puts("caught int(&)[2]"); } catch (const int*) { puts("caught int*"); } } The correct output is "caught int*", because nullptr is not an array. Clang and EDG produce the correct output. MSVC is so confident that you can't throw an array (I think they're right!) that it diagnoses the `catch` at -W4: // https://godbolt.org/z/v6M1e5ff5 warning C4843: 'const int (&)[2]': An exception handler of reference to array or function type is unreachable, use 'const int *' instead GCC also mishandles unreachable catch handlers of type "reference to function": again the correct output is "caught int*", Clang/EDG/MSVC all get it right, and MSVC diagnoses. // https://godbolt.org/z/sqoW6cPTn try { throw nullptr; } catch (int(&)()) { puts("caught int(&)()"); } catch (const int*) { puts("caught int*"); }
I think this is a dup of bug 69372.
It is a dup of bug 69372. *** This bug has been marked as a duplicate of bug 69372 ***