llvm / llvm/llvm-project

Clang crashes on out-of-line template member function definition in a wrong namespace

Open
#203,891 1 comment 0 reactions 0 assignees View on GitHub
clang
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

# Clang crashes on out-of-line template member function definition in a wrong namespace

Compiler Explorer: https://gcc.godbolt.org/z/neT94c34f

## Reproducer

```c++
struct C { template void f(); };
namespace N { template void C::f() { struct S { T* p; ~S() { delete p; } }; } }
```

First reproduces on clang 5.0.0; still reproduces on trunk.

## Assertion (from an assertion-enabled build)

```
clang++: /root/build/tools/clang/include/clang/AST/TypeNodes.inc:82:
clang::TypeInfo clang::ASTContext::getTypeInfoImpl(const clang::Type*) const:
Assertion `!T->isDependentType() && "should not see dependent types here"' failed.
```

## Backtrace (clang trunk)

```
#4 clang::ASTContext::getTypeInfoImpl(clang::Type const*) const
#5 clang::ASTContext::getTypeInfo(clang::Type const*) const
#6 clang::ASTContext::getTypeAlignIfKnown(clang::QualType, bool) const
#7 hasNewExtendedAlignment(clang::Sema&, clang::QualType)
#8 clang::Sema::ActOnCXXDelete(...)
#9 clang::Parser::ParseCXXDeleteExpression(...)
...
#19 clang::Parser::ParseLexedMethodDef
#20 clang::Parser::ParseLexedMethodDefs
#21 clang::Parser::ParseCXXMemberSpecification
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.