Skip to content

A/F "friend function specialization without template args" on illegal C++ #65139

@jmorse

Description

@jmorse

Hi,

Behold this bogus template specialisation:

template <a> class b {
     template <> friend int c< b >() {}
};

Clang / GCC / MSVC all reject this with errors and diagnostics. With assertions enabled however, clang fires the following assertion failure rather than completing:

clang: /path/clang/lib/Sema/SemaDecl.cpp:10454: clang::NamedDecl *clang::Sema::ActOnFunctionDeclarator(clang::Scope *, 
    clang::Declarator &, clang::DeclContext *, clang::TypeSourceInfo *, clang::LookupResult &, clang::MultiTemplateParamsArg,
    bool &): Assertion `HasExplicitTemplateArgs && "friend function specialization without template args"' failed.

when building with the very recent 22044f0. Godbolt link of the same: https://godbolt.org/z/7jabnhEY9 . Fiddling with Godbolt, it appears the assertion failure appeared in the 14.0.0 release, and isn't present in the 13.0.0 release.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second partycrash-on-invalid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions