https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120755
Bug ID: 120755
Summary: Catching reference to array also catches thrown
pointers
Product: gcc
Version: 15.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: blubban at gmail dot com
Target Milestone: ---
int main()
{
int* var = nullptr;
try { throw var; }
catch (int(&)[8]) { return 1; }
catch (...) { return 0; }
}
Expected: Return 0, and/or throw a compile error or warning about array
references being uncatchable (they decay to pointers if thrown).
Actual: Returns 1, despite nobody throwing a reference to size-8 array.
https://godbolt.org/z/xnaa6r4T6