| Issue |
173678
|
| Summary |
Unreachable in ASTContext::mergeTypes during Sema of function redeclaration with VLA bounds dependent on nested struct member
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
Theaamadu
|
## Compiler Explorer: https://godbolt.org/z/TKdc7YjEd
- clang start crashing on `Trunk`
- generated by fuzzer
## Console
```console
UNREACHABLE executed at /root/llvm-project/llvm/tools/clang/lib/AST/ASTContext.cpp:11744!
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: /opt/compiler-explorer/clang-assertions-trunk/bin/clang -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics <source>
1. <source>:24:50: current parser token ';'
#0 0x00000000042ecab8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x42ecab8)
#1 0x00000000042e9ee4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x42e9ee4)
#2 0x000000000422ec88 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007d6a4e842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007d6a4e8969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x00007d6a4e842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x00007d6a4e8287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x00000000042398ba (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x42398ba)
#8 0x00000000079a06c7 clang::ASTContext::mergeTypes(clang::QualType, clang::QualType, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x79a06c7)
#9 0x000000000799f9c3 clang::ASTContext::mergeTypes(clang::QualType, clang::QualType, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x799f9c3)
#10 0x000000000799fdad clang::ASTContext::mergeTypes(clang::QualType, clang::QualType, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x799fdad)
#11 0x00000000079a11e1 clang::ASTContext::mergeFunctionParameterTypes(clang::QualType, clang::QualType, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x79a11e1)
#12 0x000000000799f2eb clang::ASTContext::mergeFunctionTypes(clang::QualType, clang::QualType, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x799f2eb)
#13 0x00000000079a03b8 clang::ASTContext::mergeTypes(clang::QualType, clang::QualType, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x79a03b8)
#14 0x00000000079a2bd4 clang::ASTContext::typesAreCompatible(clang::QualType, clang::QualType, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x79a2bd4)
#15 0x0000000006df1ddb clang::Sema::MergeFunctionDecl(clang::FunctionDecl*, clang::NamedDecl*&, clang::Scope*, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6df1ddb)
#16 0x0000000006e109ac clang::Sema::CheckFunctionDeclaration(clang::Scope*, clang::FunctionDecl*, clang::LookupResult&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6e109ac)
#17 0x0000000006e16990 clang::Sema::ActOnFunctionDeclarator(clang::Scope*, clang::Declarator&, clang::DeclContext*, clang::TypeSourceInfo*, clang::LookupResult&, llvm::MutableArrayRef<clang::TemplateParameterList*>, bool&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6e16990)
#18 0x0000000006e1b5a1 clang::Sema::HandleDeclarator(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6e1b5a1)
#19 0x0000000006e1c4a0 clang::Sema::ActOnDeclarator(clang::Scope*, clang::Declarator&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6e1c4a0)
#20 0x0000000006a532c3 clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6a532c3)
#21 0x0000000006a610da clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6a610da)
#22 0x0000000006a1e78b clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6a1e78b)
#23 0x0000000006a1ef7f clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6a1ef7f)
#24 0x0000000006a26daa clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6a26daa)
#25 0x0000000006a27d45 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6a27d45)
#26 0x0000000006a08dca clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6a08dca)
#27 0x0000000004c4dde8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4c4dde8)
#28 0x0000000004f446e5 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4f446e5)
#29 0x0000000004ec497e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4ec497e)
#30 0x000000000503ea6d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x503ea6d)
#31 0x0000000000de5b4c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xde5b4c)
#32 0x0000000000ddc59a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0
#33 0x0000000000ddc71d int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::'lambda'(llvm::SmallVectorImpl<char const*>&)>(long, llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#34 0x0000000004cc0739 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#35 0x000000000422f124 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x422f124)
#36 0x0000000004cc0d4f clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#37 0x0000000004c81832 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4c81832)
#38 0x0000000004c827de clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4c827de)
#39 0x0000000004c89c35 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4c89c35)
#40 0x0000000000de1f41 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xde1f41)
#41 0x0000000000c8cf94 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xc8cf94)
#42 0x00007d6a4e829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#43 0x00007d6a4e829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#44 0x0000000000ddc035 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xddc035)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
## Code
```c
extern int m, n;
struct CombinedStruct_2 combinedVar_2;
void pa1(int (*)[1]);
void pa1(int (*)[combinedVar_2.combinedVar_1.n]); // { dg-warning "\\\[-Wvla-parameter" }
void pa1(int (*)[1]);
void pa1(int (*)[combinedVar_2.combinedVar_1.n + 1]); // { dg-warning "mismatch in bound 1 of argument 1
void ppax(int (**)[*]);
void ppax(int (**)[combinedVar_2.combinedVar_1.n]); // { dg-warning "\\\[-Wvla-parameter" }
void ppax(
int (**)[1]);
void ppax(
int (**)[combinedVar_2.combinedVar_1.n + 1]); // { dg-warning "mismatch in bound 1 of argument 1
void pa1_n(int (*)[1][combinedVar_2.combinedVar_1.n]);
void pa1_n(int (*)[1][combinedVar_2.combinedVar_1.n]);
void pa1_n(int (*)[*][combinedVar_2.combinedVar_1.n]); // { dg-warning "mismatch in bound 1 of argument 1
void pa1_n_2(int (*)[1][combinedVar_2.combinedVar_1.n][2]);
void pa1_n_2(
int (*)[1][combinedVar_2.combinedVar_1.n][*]); // { dg-warning "mismatch in bound 3 of argument 1
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs