Issue |
122493
|
Summary |
Assertion failure and invalid Wunitialized error after
|
Labels |
clang:modules
|
Assignees |
dmpolukhin
|
Reporter |
ilya-biryukov
|
After https://github.com/llvm/llvm-project/commit/38b3d87bd384a469a6618ec6a971352cb4f813ba we started seeing invalid `Wunitialized` errors in some rare cases involving modules with lambdas and an assertion failures.
See https://gcc.godbolt.org/z/GzP568fxd for the code causing this (it's a result of `-frewrite-imports`, so slightly unreadable, sorry about that).
<details>
<summary>(Click to expand) Assertion `isa<LabelDecl>(D) && "declaration not instantiated in this scope"' failed. )</summary>
```shell
clang-20: /usr/local/google/home/ibiryukov/code/llvm-project/clang/lib/Sema/SemaTemplateInstantiate.cpp:4646: llvm::PointerUnion<Decl *, LocalInstantiationScope::DeclArgumentPack *> *clang::LocalInstantiationScope::findInstantiationOf(const Decl *): Assertion `isa<LabelDecl>(D) && "declaration not instantiated in this
scope"' 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: /usr/local/google/home/ibiryukov/code/llvm-project/build/bin/clang-20 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name all.cc -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -f
no-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/usr/local/google/home/ibiryukov/repro/uninit/foobarbaz -fcoverage-compilation-dir=/usr/local/google/home/ibiryukov/repro/uninit/foobarbaz -resource-dir /usr/local/google/home/ibiry
ukov/code/llvm-project/build/lib/clang/20 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/x86_64-linux-gnu/c++/14 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/backward -internal-isystem
/usr/local/google/home/ibiryukov/code/llvm-project/build/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem
/usr/include -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fmodules -fimplicit-module-maps -fmodules-cache-path=/usr/local/google/home/ibiryukov/.cache/clang/ModuleCache -fmodules-validate-system-headers -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_
CFI_ASM=1 -o /tmp/all-46cd28.o -x c++ all.cc
1. <eof> parser at end of file
2. /usr/local/google/home/ibiryukov/repro/uninit/foobarbaz/bbb/public/sql_transform_builder.h:18:8: instantiating function definition 'www::SqlTransformBuilder::DoTransform<int>'
3. /usr/local/google/home/ibiryukov/repro/uninit/foobarbaz/bbb/public/sql_transform_builder.h:11:13: instantiating function definition 'www::DecodeHelper2<int, int>'
4. /usr/local/google/home/ibiryukov/repro/uninit/foobarbaz/bitset/set_bits2.h:13:6: instantiating function definition 'aaa::bitset::ForEachSetBit2<(lambda at /usr/local/google/home/ibiryukov/repro/uninit/foobarbaz/bbb/public/sql_transform_builder.h:12:31)>'
#0 0x0000556d9f07a4c8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /usr/local/google/home/ibiryukov/code/llvm-project/llvm/lib/Support/Unix/Signals.inc:800:13
#1 0x0000556d9f07807e llvm::sys::RunSignalHandlers() /usr/local/google/home/ibiryukov/code/llvm-project/llvm/lib/Support/Signals.cpp:106:18
#2 0x0000556d9f07ab58 SignalHandler(int) /usr/local/google/home/ibiryukov/code/llvm-project/llvm/lib/Support/Unix/Signals.inc:417:1
#3 0x00007f5fb1029590 (/lib/x86_64-linux-gnu/libc.so.6+0x3f590)
#4 0x00007f5fb10783ac __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#5 0x00007f5fb10294f2 raise ./signal/../sysdeps/posix/raise.c:27:6
#6 0x00007f5fb10124ed abort ./stdlib/abort.c:81:7
#7 0x00007f5fb1012415 _nl_load_domain ./intl/loadmsgcat.c:1177:9
#8 0x00007f5fb1022012 (/lib/x86_64-linux-gnu/libc.so.6+0x38012)
#9 0x0000556da1f9e6cf dyn_cast<clang::TagDecl, const clang::Decl> /usr/local/google/home/ibiryukov/code/llvm-project/llvm/include/llvm/Support/Casting.h:662:3
#10 0x0000556da1f9e6cf clang::LocalInstantiationScope::findInstantiationOf(clang::Decl const*) /usr/local/google/home/ibiryukov/code/llvm-project/clang/lib/Sema/SemaTemplateInstantiate.cpp:4610:32
#11 0x0000556da2031dce clang::Sema::FindInstantiatedDecl(clang::SourceLocation, clang::NamedDecl*, clang::MultiLevelTemplateArgumentList const&, bool) /usr/local/google/home/ibiryukov/code/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:6216:16
#12 0x0000556da1ffb1a1 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformDeclRefExpr(clang::DeclRefExpr*) /usr/local/google/home/ibiryukov/code/llvm-project/clang/lib/Sema/TreeTransform.h:0:44
#13 0x0000556da1ff0d22 isInvalid /usr/local/google/home/ibiryukov/code/llvm-project/clang/include/clang/Sema/Ownership.h:199:41
#14 0x0000556da1ff0d22 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformBinaryOperator(clang::BinaryOperator*) /usr/local/google/home/ibiryukov/code/llvm-project/clang/lib/Sema/TreeTransform.h:13316:11
#15 0x0000556da1ff1069 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCompoundAssignOperator(clang::CompoundAssignOperator*) /usr/local/google/home/ibiryukov/code/llvm-project/clang/lib/Sema/TreeTransform.h:13400:23
#16 0x0000556da1f9767c clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformStmt(clang::Stmt*, clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::StmtDiscardKind) /usr/local/google/home/ibiryukov/code/llvm-project/clang/lib/Sema/TreeTransform.h:4263:15
#17 0x0000556da1ff3566 isInvalid /usr/local/google/home/ibiryukov/code/llvm-project/clang/include/clang/Sema/Ownership.h:199:41
#18 0x0000556da1ff3566 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*, bool) /usr/local/google/home/ibiryukov/code/llvm-project/clang/lib/Sema/TreeTransform.h:8031:16
```
</details>
@dmpolukhin @ChuanqiXu9 any ideas on what might be going wrong here?
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs