Skip to content

[clang] Crash in clang codegen after CXXDependentScopeMemberExpr change #97483

Closed
@mikerice1969

Description

@mikerice1969

Attached test crashes in clang codegen after fd87d76. The test has been creduced from some 600,000+ lines of preprocessed Windows blender code. The crash happens in the same place in the full code (but the expression is used).

t.cpp:66:21: warning: expression result unused [-Wunused-value]
   66 |   void bl() { bf::l &m; }
      |               ~~~~~ ^~
t.cpp:143:6: note: in instantiation of member function 'bk<3>::bl' requested here
  143 |   r->bl();
      |      ^
t.cpp:133:26: note: in instantiation of function template specialization 'ci<int, int, int, int>::decode<f>' requested here
  133 |           bg->bc(cz.e(), decode(da));
      |                          ^
t.cpp:117:3: note: in instantiation of function template specialization 'ci<int, int, int, int>::cn<g>' requested here
  117 |   cn(cm);
      |   ^
t.cpp:157:4: note: in instantiation of member function 'ci<int, int, int, int>::operator()' requested here
  157 |   s(bq, db, y, dd);
      |    ^
t.cpp:162:5: note: in instantiation of function template specialization 'de<int, int, int>' requested here
  162 |     de<int, int, int>(df);
      |     ^
t.cpp:87:15: note: in instantiation of function template specialization 'v::operator()<h, h, float, 1>' requested here
   87 |   bt.template operator()<j, j, float, 1>(bq);
      |               ^
t.cpp:168:3: note: in instantiation of function template specialization 'bs<v>' requested here
  168 |   bs(bq, bt);
      |   ^
Unhandled DeclRefExpr
UNREACHABLE executed at /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CGExpr.cpp:3180!
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-cl -cc1 -triple x86_64-pc-windows-msvc19.29.30154 -emit-obj -mincremental-linker-compatible -disable-free -clear-ast-before-backend -main-file-name image_vdb.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=none -relaxed-aliasing -menable-no-infs -menable-no-nans -fapprox-func -funsafe-math-optimizations -fno-signed-zeros -mreassociate -freciprocal-math -ffp-contract=fast -fno-rounding-math -ffast-math -ffinite-math-only -complex-range=basic -mconstructor-aliases -fms-volatile -funwind-tables=2 -target-cpu x86-64 -mllvm -x86-asm-syntax=intel -tune-cpu generic -fdeprecated-macro -ferror-limit 19 -fopenmp -fno-signed-char -fno-use-cxa-atexit -fms-extensions -fms-compatibility -fms-compatibility-version=19.29.30154 -std=c++17 -finline-functions -fskip-odr-check-in-gmf -fdelayed-template-parsing -vectorize-loops -vectorize-slp -faddrsig -x c++ t.cpp
1.	<eof> parser at end of file
2.	Per-file LLVM IR generation
3.	t.cpp:66:8: Generating code for declaration 'bk<3>::bl'
 #0 0x00007fc423b55f6a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /export/iusers/mprice1/community1/llvm-project/llvm/lib/Support/Unix/Signals.inc:723:22
 #1 0x00007fc423b563b2 PrintStackTraceSignalHandler(void*) /export/iusers/mprice1/community1/llvm-project/llvm/lib/Support/Unix/Signals.inc:798:1
 #2 0x00007fc423b53ba7 llvm::sys::RunSignalHandlers() /export/iusers/mprice1/community1/llvm-project/llvm/lib/Support/Signals.cpp:105:20
 #3 0x00007fc423b55932 SignalHandler(int) /export/iusers/mprice1/community1/llvm-project/llvm/lib/Support/Unix/Signals.inc:413:1
 #4 0x00007fc4233efdb0 __restore_rt (/lib64/libc.so.6+0x59db0)
 #5 0x00007fc42343c42c __pthread_kill_implementation (/lib64/libc.so.6+0xa642c)
 #6 0x00007fc4233efd06 gsignal (/lib64/libc.so.6+0x59d06)
 #7 0x00007fc4233c27d3 abort (/lib64/libc.so.6+0x2c7d3)
 #8 0x00007fc423a3e827 bindingsErrorHandler(void*, char const*, bool) /export/iusers/mprice1/community1/llvm-project/llvm/lib/Support/ErrorHandling.cpp:222:55
 #9 0x00007fc42be3808d clang::CodeGen::CodeGenFunction::EmitDeclRefLValue(clang::DeclRefExpr const*) /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CGExpr.cpp:3181:1
#10 0x00007fc42be2e9fb clang::CodeGen::CodeGenFunction::EmitLValueHelper(clang::Expr const*, clang::CodeGen::KnownNonNull_t) /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CGExpr.cpp:1552:50
#11 0x00007fc42be2e641 clang::CodeGen::CodeGenFunction::EmitLValue(clang::Expr const*, clang::CodeGen::KnownNonNull_t) /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CGExpr.cpp:1505:22
#12 0x00007fc42be2e3d9 clang::CodeGen::CodeGenFunction::EmitCheckedLValue(clang::Expr const*, clang::CodeGen::CodeGenFunction::TypeCheckKind) /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CGExpr.cpp:1472:20
#13 0x00007fc42bebdb33 (anonymous namespace)::ScalarExprEmitter::EmitCheckedLValue(clang::Expr const*, clang::CodeGen::CodeGenFunction::TypeCheckKind) /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CGExprScalar.cpp:255:40
#14 0x00007fc42bebddf9 (anonymous namespace)::ScalarExprEmitter::EmitLoadOfLValue(clang::Expr const*) /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CGExprScalar.cpp:303:32
#15 0x00007fc42bebe9ff (anonymous namespace)::ScalarExprEmitter::VisitDeclRefExpr(clang::DeclRefExpr*) /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CGExprScalar.cpp:523:30
#16 0x00007fc42bedbd48 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) /export/iusers/mprice1/community1/llvm-project/build/tools/clang/include/clang/AST/StmtNodes.inc:456:1
#17 0x00007fc42bebe10e (anonymous namespace)::ScalarExprEmitter::Visit(clang::Expr*) /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CGExprScalar.cpp:422:57
#18 0x00007fc42bec8530 (anonymous namespace)::ScalarExprEmitter::VisitCastExpr(clang::CastExpr*) /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CGExprScalar.cpp:2479:17
#19 0x00007fc42bedd415 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::VisitImplicitCastExpr(clang::ImplicitCastExpr*) /export/iusers/mprice1/community1/llvm-project/build/tools/clang/include/clang/AST/StmtNodes.inc:516:1
#20 0x00007fc42bedbe08 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) /export/iusers/mprice1/community1/llvm-project/build/tools/clang/include/clang/AST/StmtNodes.inc:516:1
#21 0x00007fc42bebe10e (anonymous namespace)::ScalarExprEmitter::Visit(clang::Expr*) /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CGExprScalar.cpp:422:57
#22 0x00007fc42bed95ab clang::CodeGen::CodeGenFunction::EmitPromotedScalarExpr(clang::Expr const*, clang::QualType) /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CGExprScalar.cpp:5516:64
#23 0x00007fc42bece645 (anonymous namespace)::ScalarExprEmitter::EmitBinOps(clang::BinaryOperator const*, clang::QualType) /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CGExprScalar.cpp:3467:14
#24 0x00007fc42bec0612 (anonymous namespace)::ScalarExprEmitter::VisitBinAnd(clang::BinaryOperator const*) /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CGExprScalar.cpp:871:3
#25 0x00007fc42bedb2fb clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) /export/iusers/mprice1/community1/llvm-project/clang/include/clang/AST/StmtVisitor.h:68:26
#26 0x00007fc42bebe10e (anonymous namespace)::ScalarExprEmitter::Visit(clang::Expr*) /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CGExprScalar.cpp:422:57
#27 0x00007fc42bed93a5 clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CGExprScalar.cpp:5485:1
#28 0x00007fc42be279f2 clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CGExpr.cpp:229:23
#29 0x00007fc42be278e8 clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CGExpr.cpp:204:29
#30 0x00007fc42c077bc4 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CGStmt.cpp:130:56
#31 0x00007fc42c078fea clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CGStmt.cpp:514:3
#32 0x00007fc42c140cf6 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:1300:33
#33 0x00007fc42c141cdd clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:1526:21
#34 0x00007fc42c172941 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:5900:3
#35 0x00007fc42c16aec6 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:4100:28
#36 0x00007fc42c166b76 clang::CodeGen::CodeGenModule::EmitDeferred() /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:3197:31
#37 0x00007fc42c166bc4 clang::CodeGen::CodeGenModule::EmitDeferred() /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:3199:7
#38 0x00007fc42c166bc4 clang::CodeGen::CodeGenModule::EmitDeferred() /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:3199:7
#39 0x00007fc42c166bc4 clang::CodeGen::CodeGenModule::EmitDeferred() /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:3199:7
#40 0x00007fc42c166bc4 clang::CodeGen::CodeGenModule::EmitDeferred() /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:3199:7
#41 0x00007fc42c166bc4 clang::CodeGen::CodeGenModule::EmitDeferred() /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:3199:7
#42 0x00007fc42c166bc4 clang::CodeGen::CodeGenModule::EmitDeferred() /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:3199:7
#43 0x00007fc42c166bc4 clang::CodeGen::CodeGenModule::EmitDeferred() /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:3199:7
#44 0x00007fc42c166bc4 clang::CodeGen::CodeGenModule::EmitDeferred() /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:3199:7
#45 0x00007fc42c166bc4 clang::CodeGen::CodeGenModule::EmitDeferred() /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:3199:7
#46 0x00007fc42c166bc4 clang::CodeGen::CodeGenModule::EmitDeferred() /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:3199:7
#47 0x00007fc42c15a80b clang::CodeGen::CodeGenModule::Release() /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:845:23
#48 0x00007fc42c3240a5 (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/ModuleBuilder.cpp:291:11
#49 0x00007fc42c123928 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:283:9
#50 0x00007fc41d3bdef0 clang::ParseAST(clang::Sema&, bool, bool) /export/iusers/mprice1/community1/llvm-project/clang/lib/Parse/ParseAST.cpp:183:14
#51 0x00007fc4289ec228 clang::ASTFrontendAction::ExecuteAction() /export/iusers/mprice1/community1/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1192:11
#52 0x00007fc42c12801f clang::CodeGenAction::ExecuteAction() /export/iusers/mprice1/community1/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1147:5
#53 0x00007fc4289ebb41 clang::FrontendAction::Execute() /export/iusers/mprice1/community1/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1082:38
#54 0x00007fc4288ee589 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /export/iusers/mprice1/community1/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1061:42
#55 0x00007fc42e24297b clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /export/iusers/mprice1/community1/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:280:38
#56 0x000000000041df72 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /export/iusers/mprice1/community1/llvm-project/clang/tools/driver/cc1_main.cpp:232:40
#57 0x0000000000410391 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) /export/iusers/mprice1/community1/llvm-project/clang/tools/driver/driver.cpp:215:20
#58 0x0000000000410886 clang_main(int, char**, llvm::ToolContext const&) /export/iusers/mprice1/community1/llvm-project/clang/tools/driver/driver.cpp:256:26
#59 0x0000000000446cc5 main /export/iusers/mprice1/community1/llvm-project/build/tools/clang/tools/driver/clang-driver.cpp:17:20
#60 0x00007fc4233dae50 __libc_start_call_main (/lib64/libc.so.6+0x44e50)
#61 0x00007fc4233daefc __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x44efc)
#62 0x000000000040f7d5 _start (/localdisk2/mprice1/community1/llvm-project/build/bin/clang-19+0x40f7d5)
t.sh: line 1: 3845825 Aborted                 (core dumped) clang-cl "-cc1" "-triple" "x86_64-pc-windows-msvc19.29.30154" "-emit-obj" "-mincremental-linker-compatible" "-disable-free" "-clear-ast-before-backend" "-main-file-name" "image_vdb.cpp" "-mrelocation-model" "pic" "-pic-level" "2" "-mframe-pointer=none" "-relaxed-aliasing" "-menable-no-infs" "-menable-no-nans" "-fapprox-func" "-funsafe-math-optimizations" "-fno-signed-zeros" "-mreassociate" "-freciprocal-math" "-ffp-contract=fast" "-fno-rounding-math" "-ffast-math" "-ffinite-math-only" "-complex-range=basic" "-mconstructor-aliases" "-fms-volatile" "-funwind-tables=2" "-target-cpu" "x86-64" "-mllvm" "-x86-asm-syntax=intel" "-tune-cpu" "generic" "-fdeprecated-macro" "-ferror-limit" "19" "-fopenmp" "-fno-signed-char" "-fno-use-cxa-atexit" "-fms-extensions" "-fms-compatibility" "-fms-compatibility-version=19.29.30154" "-std=c++17" "-finline-functions" "-fskip-odr-check-in-gmf" "-fdelayed-template-parsing" "-vectorize-loops" "-vectorize-slp" "-faddrsig" "-x" "c++" "t.cpp"

testcase.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"crashPrefer [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