Skip to content

inline namespace in global scope causes crash #509

@NKID00

Description

@NKID00

The following input source

inline namespace ns {
    using T = void;
}

compiles but causes cppinsights to crash. The following stack trace is generated:

 #0 0x00007fd6f8cf7d01 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-14/lib/libLLVM-14.so.1+0xe3fd01)
 #1 0x00007fd6f8cf5a0c llvm::sys::RunSignalHandlers() (/usr/lib/llvm-14/lib/libLLVM-14.so.1+0xe3da0c)
 #2 0x00007fd6f8cf8236 (/usr/lib/llvm-14/lib/libLLVM-14.so.1+0xe40236)
 #3 0x00007fd6f7a80520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x0000559e2158c716 clang::DeclContext::getDeclKind() const /usr/lib/llvm-14/include/clang/AST/DeclBase.h:1862:52
 #5 0x0000559e216dde9c clang::DeclContext::isTranslationUnit() const /usr/lib/llvm-14/include/clang/AST/DeclBase.h:1944:35
 #6 0x0000559e216da223 clang::insights::details::GetScope(clang::DeclContext const*, clang::insights::details::RemoveCurrentScope) .../cppinsights/InsightsHelpers.cpp:465:35
 #7 0x0000559e216da6d0 clang::insights::GetName[abi:cxx11](clang::NamedDecl const&, clang::insights::QualifiedName) .../cppinsights/InsightsHelpers.cpp:959:87
 #8 0x0000559e21579074 clang::insights::CodeGenerator::InsertArg(clang::TypeAliasDecl const*) .../cppinsights/CodeGenerator.cpp:2399:31
 #9 0x0000559e2157f610 clang::insights::CodeGenerator::InsertArg(clang::Decl const*) .../cppinsights/CodeGeneratorTypes.h:26:1
#10 0x0000559e2157afbf clang::insights::CodeGenerator::InsertArg(clang::NamespaceDecl const*) .../cppinsights/CodeGenerator.cpp:2779:40
#11 0x0000559e2157f9bc clang::insights::CodeGenerator::InsertArg(clang::Decl const*) .../cppinsights/CodeGeneratorTypes.h:44:1
#12 0x0000559e216e7537 clang::insights::RecordDeclHandler::run(clang::ast_matchers::MatchFinder::MatchResult const&) .../cppinsights/RecordDeclHandler.cpp:76:9
#13 0x0000559e2174c1f7 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::MatchVisitor::visitMatch(clang::ast_matchers::BoundNodes const&) ASTMatchFinder.cpp.o:0:0
#14 0x0000559e2177dcac clang::ast_matchers::internal::BoundNodesTreeBuilder::visitMatches(clang::ast_matchers::internal::BoundNodesTreeBuilder::Visitor*) (.../insights+0x6e1cac)
#15 0x0000559e2174bc77 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::matchWithFilter(clang::DynTypedNode const&) ASTMatchFinder.cpp.o:0:0
#16 0x0000559e2174de2f clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl(clang::Decl*) ASTMatchFinder.cpp.o:0:0
#17 0x0000559e217562bb clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseTranslationUnitDecl(clang::TranslationUnitDecl*) ASTMatchFinder.cpp.o:0:0
#18 0x0000559e2174e1bf clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl(clang::Decl*) ASTMatchFinder.cpp.o:0:0
#19 0x0000559e2171f687 clang::ast_matchers::MatchFinder::matchAST(clang::ASTContext&) (.../insights+0x683687)
#20 0x0000559e216cf1f2 CppInsightASTConsumer::HandleTranslationUnit(clang::ASTContext&) .../cppinsights/Insights.cpp:114:48
#21 0x0000559e21bc6004 clang::ParseAST(clang::Sema&, bool, bool) (.../insights+0xb2a004)
#22 0x0000559e2182fff7 clang::FrontendAction::Execute() (.../insights+0x793ff7)
#23 0x0000559e217a5356 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (.../insights+0x709356)
#24 0x0000559e217102a3 clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) (.../insights+0x6742a3)
#25 0x0000559e2170fff5 clang::tooling::ToolInvocation::runInvocation(char const*, clang::driver::Compilation*, std::shared_ptr<clang::CompilerInvocation>, std::shared_ptr<clang::PCHContainerOperations>) (.../insights+0x673ff5)
#26 0x0000559e2170eee3 clang::tooling::ToolInvocation::run() (.../insights+0x672ee3)
#27 0x0000559e21711b8e clang::tooling::ClangTool::run(clang::tooling::ToolAction*) (.../insights+0x675b8e)
#28 0x0000559e216cc463 main .../cppinsights/Insights.cpp:255:20
#29 0x00007fd6f7a67d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#30 0x00007fd6f7a67e40 call_init ./csu/../csu/libc-start.c:128:20
#31 0x00007fd6f7a67e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#32 0x0000559e2156e555 _start (.../insights+0x4d2555)
Segmentation fault (core dumped)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions