-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Closed as duplicate of#63242
Clang 13-15 segfault during template instantiation with ill-formed nested type and RTTI operation#149479
Bug
Copy link
Labels
c++20clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"crash-on-invalidduplicateResolved as duplicateResolved as duplicate
Description
Description
Clang versions 13-15 crash with segmentation fault when compiling C++20 code that:
- Declares a local class with the same name as an outer scoped enum
- Attempts to initialize that class with an enum value
- Uses
typeid
operator on the invalid object
Steps to Reproduce
- Save the following code as
crash.cpp
:
#include <typeinfo>
struct scoped {
enum class scoped2 { RED };
};
template<auto>
struct S {
void f() {
class scoped2 e = scoped::scoped2::RED;
typeid(e);
}
};
int main() {
S<scoped::scoped2::RED>{}.f();
}
- Compile with affected Clang versions:
clang++-13 -std=c++20 crash.cpp
clang++-14 -std=c++20 crash.cpp
clang++-15 -std=c++20 crash.cpp
Expected Behavior
Compiler should report type errors without crashing.
Actual Behavior
Compiler crashes with segmentation fault during template instantiation.
Affected Versions
- Clang 13.0.1
- Clang 14.0.0
- Clang 15.0.7
Environment
- OS: Ubuntu 22.04 LTS
- Architecture: x86_64
Notes
Clang 11 behaves correctly (reports errors without crashing).
Expected Behavior
Compiler should report type errors without crashing
Actual Behavior
Compiler crashes with segmentation fault during template instantiation
Affected Versions
- Clang 13.0.1
- Clang 14.0.0
- Clang 15.0.7
Additional Info
- Clang 11 behaves correctly (reports errors without crashing)
- Crash occurs in
Sema::SubstStmt
andSema::InstantiateFunctionDefinition
- Stack trace and preprocessed files generated automatically by compiler
Metadata
Metadata
Assignees
Labels
c++20clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"crash-on-invalidduplicateResolved as duplicateResolved as duplicate