llvm / llvm/llvm-project

[clang] Assertion `S.Context.hasSameUnqualifiedType(SubInit[0]->getType(), DestType) && "Deduced to other type?"' failed.

Open
#200,834 4 comments 0 reactions 0 assignees View on GitHub
clang:frontend confirmed crash generated by fuzzer regression:20
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Reproducer:
https://godbolt.org/z/c6qzffsq5
```cpp
void foo() {
typedef int arr[42];
while (arr[x] = {0})
;
}
```

Backtrace:
```console
clang++: /root/llvm-project/llvm/tools/clang/lib/Sema/SemaInit.cpp:5103: void TryListInitialization(clang::Sema&, const clang::InitializedEntity&, const clang::InitializationKind&, clang::InitListExpr*, clang::InitializationSequence&, bool): Assertion `S.Context.hasSameUnqualifiedType(SubInit[0]->getType(), DestType) && "Deduced to other type?"' 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: /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 -std=c++2c
1. :3:22: current parser token ')'
2. :1:12: parsing function body 'foo'
3. :1:12: in compound statement ('{}')
#0 0x00000000044b3ad8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44b3ad8)
#1 0x00000000044b0914 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44b0914)
#2 0x00000000044b0f34 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44b0f34)
#3 0x00000000043ef228 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#4 0x00007ad18c242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#5 0x00007ad18c2969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#6 0x00007ad18c242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#7 0x00007ad18c2287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#8 0x00007ad18c22871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#9 0x00007ad18c239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#10 0x000000000749d2c3 TryListInitialization(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, clang::InitListExpr*, clang::InitializationSequence&, bool) SemaInit.cpp:0:0
#11 0x000000000749db64 clang::InitializationSequence::InitializeFrom(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x749db64)
#12 0x00000000071bab3a clang::Sema::AddInitializerToDecl(clang::Decl*, clang::Expr*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x71bab3a)
#13 0x0000000006e5e5a6 clang::Parser::ParseCXXCondition(clang::ActionResult*, clang::SourceLocation, clang::Sema::ConditionKind, bool, clang::Parser::ForRangeInfo*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e5e5a6)
#14 0x0000000006ec945d clang::Parser::ParseParenExprOrCondition(clang::ActionResult*, clang::Sema::ConditionResult&, clang::SourceLocation, clang::Sema::ConditionKind, clang::SourceLocation&, clang::SourceLocation&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6ec945d)
#15 0x0000000006ed0dc7 clang::Parser::ParseWhileStatement(clang::SourceLocation*, clang::LabelDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6ed0dc7)
#16 0x0000000006ecbd5e clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::LabelDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6ecbd5e)
#17 0x0000000006ecccc9 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::LabelDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6ecccc9)
#18 0x0000000006ed54ee clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6ed54ee)
#19 0x0000000006ed5d0a clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6ed5d0a)
#20 0x0000000006dda0a3 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::LateParsedAttrList*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6dda0a3)
#21 0x0000000006e11373 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+++0x6e11373)
#22 0x0000000006dcd5eb clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6dcd5eb)
#23 0x0000000006dcddef clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6dcddef)
#24 0x0000000006dd58b1 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6dd58b1)
#25 0x0000000006dd67e5 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6dd67e5)
#26 0x0000000006dd6bd0 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6dd6bd0)
#27 0x0000000006db7653 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6db7653)
#28 0x0000000004fbbe98 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4fbbe98)
#29 0x00000000052ec7f8 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x52ec7f8)
#30 0x000000000526bc10 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x526bc10)
#31 0x00000000053ea22d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x53ea22d)
#32 0x0000000000e131db cc1_main(llvm::ArrayRef, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xe131db)
#33 0x0000000000e09b8a ExecuteCC1Tool(llvm::SmallVectorImpl&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr) driver.cpp:0:0
#34 0x0000000000e09d0d int llvm::function_ref&)>::callback_fn&)>(long, llvm::SmallVectorImpl&) driver.cpp:0:0
#35 0x000000000502cf79 void llvm::function_ref::callback_fn>, std::__cxx11::basic_string, std::allocator>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#36 0x00000000043ef664 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43ef664)
#37 0x000000000502d5c6 clang::driver::CC1Command::Execute(llvm::ArrayRef>, std::__cxx11::basic_string, std::allocator>*, bool*) const (.part.0) Job.cpp:0:0
#38 0x0000000004feb5f2 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4feb5f2)
#39 0x0000000004fec59e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4fec59e)
#40 0x0000000004ff41c5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4ff41c5)
#41 0x0000000000e0f5b4 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xe0f5b4)
#42 0x0000000000cb26da main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcb26da)
#43 0x00007ad18c229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#44 0x00007ad18c229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#45 0x0000000000e09625 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xe09625)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
Compiler returned: 134
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.