Skip to content

Catching function types turns into catching their respective pointers #145190

Closed as not planned
@Alcaro

Description

@Alcaro
template<typename T>
void fn()
{
    try {}
    catch (T) {}
}
int main() { fn<int(int)>(); }

https://godbolt.org/z/K8rdsKbMT

Expected: Error. T is a function type, can't have a variable like that.

Actual: Clang thinks it says catch (T*), as can be seen if you add a second catch. https://godbolt.org/z/q7T43oW6n

(Fun fact: GCC is equally wrong in the opposite direction, by erroring so hard it segfaults. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120754)

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepts-invalidclang:frontendLanguage frontend issues, e.g. anything involving "Sema"invalidResolved as invalid, i.e. not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions