Skip to content

clang allows looser exception specification in explicit template instantiation #14669

@alexey-bataev

Description

@alexey-bataev
Bugzilla Link 14297
Version trunk
OS MacOS X
CC @DougGregor

Extended Description

According to 15.4p3 "If any declaration of a function has an exception-specification, all declarations, including the definition and an explicit
specialization, of that function shall have an exception-specification with the same set of type-ids".

Clang does not generate error message for the following example

struct SomeStruct{};
template void Foo(T i) throw(T) { throw i; }
template void Foo(int a) throw (char); // explicit instantiation, argument is deduced. Wrong exception specification is provided

int main() {
try {
SomeStruct slawa;
Foo(slawa);
}
catch(...) { ;}
return(0);
}

clang++ -c test.cpp

Alexey Bataev
Software Engineer
Intel Compiler Team
Intel Corp.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillac++clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions