Skip to content

[18 regression] Assertion `!isNull() && "Cannot retrieve a NULL type pointer"' failed #85343

@berolinux

Description

@berolinux
$ clang++ -c test.cc
test.cc:16:32: warning: expression result unused [-Wunused-value]
   16 |   template <typename f> d(f) { e<bool(int), f>::ba; }
      |                                ^~~~~~~~~~~~~~~~~~~
test.cc:19:20: note: in instantiation of function template specialization 'd<bool (int)>::d<a::(lambda at test.cc:19:20)>' requested here
   19 |   d<bool(int)> b = [=](auto) { [this] {}; };
      |                    ^
clang++: /builddir/build/BUILD/llvm-project-18.1.1.src/clang/include/clang/AST/Type.h:753: const ExtQualsTypeCommonBase *clang::QualType::getCommonPtr() const: Assertion `!isNull() && "Cannot retrieve a NULL type pointer"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: clang++ -c test.cc
1.      <eof> parser at end of file
2.      test.cc:16:25: instantiating function definition 'd<bool (int)>::d<a::(lambda at test.cc:19:20)>'
3.      test.cc:13:15: instantiating function definition 'e<bool (int), a::(lambda at test.cc:19:20)>::ba'
4.      test.cc:8:39: instantiating function definition 'ao<bool, a::(lambda at test.cc:19:20)>'
5.      test.cc:4:30: instantiating class definition 'ac<a::(lambda at test.cc:19:20)>'
6.      test.cc:19:20: instantiating function definition 'a::(anonymous class)::operator()<a::(lambda at test.cc:19:20) (*)()>'
 #0 0x00007f6d59d9a576 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib64/libLLVM.so.18.1+0x459a576)
 #1 0x00007f6d59d991ea llvm::sys::RunSignalHandlers() (/usr/lib64/libLLVM.so.18.1+0x45991ea)
 #2 0x00007f6d59cb0dce (/usr/lib64/libLLVM.so.18.1+0x44b0dce)
 #3 0x00007f6d55253690 (/usr/lib64/libc.so.6+0x3f690)
 #4 0x00007f6d552a2edc (/usr/lib64/libc.so.6+0x8eedc)
 #5 0x00007f6d552535e2 raise (/usr/lib64/libc.so.6+0x3f5e2)
 #6 0x00007f6d5523c4ad abort (/usr/lib64/libc.so.6+0x284ad)
 #7 0x00007f6d5523c3d5 (/usr/lib64/libc.so.6+0x283d5)
 #8 0x00007f6d5524c052 (/usr/lib64/libc.so.6+0x38052)
 #9 0x00007f6d61cf03b4 clang::InitializationSequence::InitializeFrom(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>, bool, bool) (/usr/lib64/libclang-cpp.so.18.1+0x28f03b4)
#10 0x00007f6d61d22dd7 clang::Sema::BuildCaptureInit(clang::sema::Capture const&, clang::SourceLocation, bool) (/usr/lib64/libclang-cpp.so.18.1+0x2922dd7)
#11 0x00007f6d61d2360d clang::Sema::BuildLambdaExpr(clang::SourceLocation, clang::SourceLocation, clang::sema::LambdaScopeInfo*) (/usr/lib64/libclang-cpp.so.18.1+0x292360d)
#12 0x00007f6d620b4e5c (/usr/lib64/libclang-cpp.so.18.1+0x2cb4e5c)
#13 0x00007f6d62084eae (/usr/lib64/libclang-cpp.so.18.1+0x2c84eae)
#14 0x00007f6d620916b9 (/usr/lib64/libclang-cpp.so.18.1+0x2c916b9)
#15 0x00007f6d6209a7ed (/usr/lib64/libclang-cpp.so.18.1+0x2c9a7ed)
#16 0x00007f6d620c00b6 clang::Sema::SubstStmt(clang::Stmt*, clang::MultiLevelTemplateArgumentList const&) (/usr/lib64/libclang-cpp.so.18.1+0x2cc00b6)
#17 0x00007f6d620cf659 clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) (/usr/lib64/libclang-cpp.so.18.1+0x2ccf659)
#18 0x00007f6d62014ace clang::Sema::DeduceReturnType(clang::FunctionDecl*, clang::SourceLocation, bool) (/usr/lib64/libclang-cpp.so.18.1+0x2c14ace)
#19 0x00007f6d61ac741a clang::Sema::DiagnoseUseOfDecl(clang::NamedDecl*, llvm::ArrayRef<clang::SourceLocation>, clang::ObjCInterfaceDecl const*, bool, bool, clang::ObjCInterfaceDecl*, bool) (/usr/lib64/libclang-cpp.so.18.1+0x26c741a)
#20 0x00007f6d61e9a977 (/usr/lib64/libclang-cpp.so.18.1+0x2a9a977)
#21 0x00007f6d61eb5f2e clang::Sema::BuildCallToObjectOfClassType(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation) (/usr/lib64/libclang-cpp.so.18.1+0x2ab5f2e)
#22 0x00007f6d61b1754a clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, bool) (/usr/lib64/libclang-cpp.so.18.1+0x271754a)
#23 0x00007f6d61b7606f clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*) (/usr/lib64/libclang-cpp.so.18.1+0x277606f)
#24 0x00007f6d62088525 (/usr/lib64/libclang-cpp.so.18.1+0x2c88525)
#25 0x00007f6d62074008 (/usr/lib64/libclang-cpp.so.18.1+0x2c74008)
#26 0x00007f6d62071521 (/usr/lib64/libclang-cpp.so.18.1+0x2c71521)
#27 0x00007f6d6209f942 (/usr/lib64/libclang-cpp.so.18.1+0x2c9f942)
#28 0x00007f6d6209dca5 (/usr/lib64/libclang-cpp.so.18.1+0x2c9dca5)
#29 0x00007f6d6207aa2d (/usr/lib64/libclang-cpp.so.18.1+0x2c7aa2d)
#30 0x00007f6d62076ca0 (/usr/lib64/libclang-cpp.so.18.1+0x2c76ca0)
#31 0x00007f6d62071521 (/usr/lib64/libclang-cpp.so.18.1+0x2c71521)
#32 0x00007f6d620d4984 clang::TemplateDeclInstantiator::VisitVarTemplateSpecializationDecl(clang::VarTemplateDecl*, clang::VarDecl*, clang::TemplateArgumentListInfo const&, llvm::ArrayRef<clang::TemplateArgument>, clang::VarTemplateSpecializationDecl*) (/usr/lib64/libclang-cpp.so.18.1+0x2cd4984)
#33 0x00007f6d621221a4 clang::Sema::BuildVarTemplateInstantiation(clang::VarTemplateDecl*, clang::VarDecl*, clang::TemplateArgumentList const&, clang::TemplateArgumentListInfo const&, llvm::SmallVectorImpl<clang::TemplateArgument>&, clang::SourceLocation, llvm::SmallVector<clang::Sema::LateInstantiatedAttribute, 16u>*, clang::LocalInstantiationScope*) (/usr/lib64/libclang-cpp.so.18.1+0x2d221a4)
#34 0x00007f6d61f5aff3 clang::Sema::CheckVarTemplateId(clang::VarTemplateDecl*, clang::SourceLocation, clang::SourceLocation, clang::TemplateArgumentListInfo const&) (/usr/lib64/libclang-cpp.so.18.1+0x2b5aff3)
#35 0x00007f6d61f5a5f7 clang::Sema::CheckVarTemplateId(clang::CXXScopeSpec const&, clang::DeclarationNameInfo const&, clang::VarTemplateDecl*, clang::SourceLocation, clang::TemplateArgumentListInfo const*) (/usr/lib64/libclang-cpp.so.18.1+0x2b5a5f7)
#36 0x00007f6d61f5a278 clang::Sema::BuildTemplateIdExpr(clang::CXXScopeSpec const&, clang::SourceLocation, clang::LookupResult&, bool, clang::TemplateArgumentListInfo const*) (/usr/lib64/libclang-cpp.so.18.1+0x2b5a278)
#37 0x00007f6d62080ca9 (/usr/lib64/libclang-cpp.so.18.1+0x2c80ca9)
#38 0x00007f6d62074008 (/usr/lib64/libclang-cpp.so.18.1+0x2c74008)
#39 0x00007f6d62071521 (/usr/lib64/libclang-cpp.so.18.1+0x2c71521)
#40 0x00007f6d6210f353 clang::TemplateDeclInstantiator::VisitFieldDecl(clang::FieldDecl*) (/usr/lib64/libclang-cpp.so.18.1+0x2d0f353)
#41 0x00007f6d620bc825 clang::Sema::InstantiateClass(clang::SourceLocation, clang::CXXRecordDecl*, clang::CXXRecordDecl*, clang::MultiLevelTemplateArgumentList const&, clang::TemplateSpecializationKind, bool) (/usr/lib64/libclang-cpp.so.18.1+0x2cbc825)
#42 0x00007f6d620bedf1 clang::Sema::InstantiateClassTemplateSpecialization(clang::SourceLocation, clang::ClassTemplateSpecializationDecl*, clang::TemplateSpecializationKind, bool) (/usr/lib64/libclang-cpp.so.18.1+0x2cbedf1)
#43 0x00007f6d62152180 (/usr/lib64/libclang-cpp.so.18.1+0x2d52180)
#44 0x00007f6d6173c5c9 clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/usr/lib64/libclang-cpp.so.18.1+0x233c5c9)
#45 0x00007f6d62151bbd clang::Sema::RequireCompleteTypeImpl(clang::SourceLocation, clang::QualType, clang::Sema::CompleteTypeKind, clang::Sema::TypeDiagnoser*) (/usr/lib64/libclang-cpp.so.18.1+0x2d51bbd)
#46 0x00007f6d62151065 clang::Sema::RequireCompleteType(clang::SourceLocation, clang::QualType, clang::Sema::CompleteTypeKind, clang::Sema::TypeDiagnoser&) (/usr/lib64/libclang-cpp.so.18.1+0x2d51065)
#47 0x00007f6d61969f8b clang::Sema::ActOnUninitializedDecl(clang::Decl*) (/usr/lib64/libclang-cpp.so.18.1+0x2569f8b)
#48 0x00007f6d620d44fb clang::Sema::InstantiateVariableInitializer(clang::VarDecl*, clang::VarDecl*, clang::MultiLevelTemplateArgumentList const&) (/usr/lib64/libclang-cpp.so.18.1+0x2cd44fb)
#49 0x00007f6d620d5785 clang::Sema::BuildVariableInstantiation(clang::VarDecl*, clang::VarDecl*, clang::MultiLevelTemplateArgumentList const&, llvm::SmallVector<clang::Sema::LateInstantiatedAttribute, 16u>*, clang::DeclContext*, clang::LocalInstantiationScope*, bool, clang::VarTemplateSpecializationDecl*) (/usr/lib64/libclang-cpp.so.18.1+0x2cd5785)
#50 0x00007f6d6210ede4 clang::TemplateDeclInstantiator::VisitVarDecl(clang::VarDecl*, bool, llvm::ArrayRef<clang::BindingDecl*>*) (/usr/lib64/libclang-cpp.so.18.1+0x2d0ede4)
#51 0x00007f6d620d4764 clang::Sema::SubstDecl(clang::Decl*, clang::DeclContext*, clang::MultiLevelTemplateArgumentList const&) (/usr/lib64/libclang-cpp.so.18.1+0x2cd4764)
#52 0x00007f6d62097249 (/usr/lib64/libclang-cpp.so.18.1+0x2c97249)
#53 0x00007f6d6209a7ed (/usr/lib64/libclang-cpp.so.18.1+0x2c9a7ed)
#54 0x00007f6d620c00b6 clang::Sema::SubstStmt(clang::Stmt*, clang::MultiLevelTemplateArgumentList const&) (/usr/lib64/libclang-cpp.so.18.1+0x2cc00b6)
#55 0x00007f6d620cf659 clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) (/usr/lib64/libclang-cpp.so.18.1+0x2ccf659)
#56 0x00007f6d620d2592 clang::Sema::PerformPendingInstantiations(bool) (/usr/lib64/libclang-cpp.so.18.1+0x2cd2592)
#57 0x00007f6d620cf75e clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) (/usr/lib64/libclang-cpp.so.18.1+0x2ccf75e)
#58 0x00007f6d620d2592 clang::Sema::PerformPendingInstantiations(bool) (/usr/lib64/libclang-cpp.so.18.1+0x2cd2592)
#59 0x00007f6d620cf75e clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) (/usr/lib64/libclang-cpp.so.18.1+0x2ccf75e)
#60 0x00007f6d620d2592 clang::Sema::PerformPendingInstantiations(bool) (/usr/lib64/libclang-cpp.so.18.1+0x2cd2592)
#61 0x00007f6d6173fdf2 clang::Sema::ActOnEndOfTranslationUnitFragment(clang::Sema::TUFragmentKind) (/usr/lib64/libclang-cpp.so.18.1+0x233fdf2)
#62 0x00007f6d617443e7 clang::Sema::ActOnEndOfTranslationUnit() (/usr/lib64/libclang-cpp.so.18.1+0x23443e7)
#63 0x00007f6d60d432a8 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/usr/lib64/libclang-cpp.so.18.1+0x19432a8)
#64 0x00007f6d60c452fe clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib64/libclang-cpp.so.18.1+0x18452fe)
#65 0x00007f6d6318285b clang::FrontendAction::Execute() (/usr/lib64/libclang-cpp.so.18.1+0x3d8285b)
#66 0x00007f6d630e6b09 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib64/libclang-cpp.so.18.1+0x3ce6b09)
#67 0x00007f6d63201daa clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib64/libclang-cpp.so.18.1+0x3e01daa)
#68 0x000056526fcfd036 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/bin/clang-18+0x17036)
#69 0x000056526fcf8cef (/usr/bin/clang-18+0x12cef)
#70 0x00007f6d62cc236b (/usr/lib64/libclang-cpp.so.18.1+0x38c236b)
#71 0x00007f6d59cb1033 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/usr/lib64/libLLVM.so.18.1+0x44b1033)
#72 0x00007f6d62cc2253 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/usr/lib64/libclang-cpp.so.18.1+0x38c2253)
#73 0x00007f6d62c7aec7 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/usr/lib64/libclang-cpp.so.18.1+0x387aec7)
#74 0x00007f6d62c7b3de clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/usr/lib64/libclang-cpp.so.18.1+0x387b3de)
#75 0x00007f6d62cbd91f clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/usr/lib64/libclang-cpp.so.18.1+0x38bd91f)
#76 0x000056526fcf8265 clang_main(int, char**, llvm::ToolContext const&) (/usr/bin/clang-18+0x12265)
#77 0x000056526fd07f36 main (/usr/bin/clang-18+0x21f36)
#78 0x00007f6d5523dc0a (/usr/lib64/libc.so.6+0x29c0a)
#79 0x00007f6d5523dcc5 __libc_start_main (/usr/lib64/libc.so.6+0x29cc5)
#80 0x000056526fcf4e71 _start (/usr/bin/clang-18+0xee71)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
OpenMandriva 18.1.1-1 clang version 18.1.1 (/builddir/build/BUILD/llvm-project-18.1.1.src/clang c7328f22742eee71eda2d4404b1dcc8d9383e694)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang++: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang++: note: diagnostic msg: /tmp/test-74a276.cpp
clang++: note: diagnostic msg: /tmp/test-74a276.sh
clang++: note: diagnostic msg: 

********************

Test case extracted from wayfire:

template <typename> struct d;
template <typename c> auto ab() -> c;
template <typename, typename> struct e {};
template <typename f> struct ac {
  template <typename h> static e<decltype(ab<h>()(ab<h>)), int> i;
  decltype(i<f>) j;
};
template <typename, typename an> void ao(an) { ac<an> a; }
template <typename f> struct aw {
  static f *ax();
};
template <typename am, typename f, typename g> struct e<am(g), f> {
  static void ba() { ao<am>(*aw<f>::ax()); }
};
template <typename am, typename g> struct d<am(g)> {
  template <typename f> d(f) { e<bool(int), f>::ba; }
};
struct a {
  d<bool(int)> b = [=](auto) { [this] {}; };
};
void b() { new a; }

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second partycrashPrefer [crash-on-valid] or [crash-on-invalid]

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions