https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104661
Bug ID: 104661 Summary: Catching exception by const value when exception-object has lvalue-reference constructor Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: fchelnokov at gmail dot com Target Milestone: --- This program ``` struct A { A() {} A(A&) {} }; int main() { try { throw A{}; } catch ( const A ) { } } ``` is presumably valid and accepted by Clang and MSVC, but GCC complains: ``` error: binding reference of type 'A&' to 'const A' discards qualifiers 10 | catch ( const A ) { | ^ <source>:3:7: note: initializing argument 1 of 'A::A(A&)' 3 | A(A&) {} | ^~ ``` Demo: https://gcc.godbolt.org/z/as671TGqs