Issue |
130840
|
Summary |
Assertion failure in clang::Sema::BuildBitIntType when handling _BitInt(N) with excessive bit-width
|
Labels |
clang
|
Assignees |
|
Reporter |
bi6c
|
Compiler Explorer: https://godbolt.org/z/64s1TK9xx
- generated by fuzzer
- tested with flag -std=c2x
```console
clang: /root/llvm-project/llvm/include/llvm/ADT/APInt.h:1523: uint64_t llvm::APInt::getZExtValue() const: Assertion `getActiveBits() <= 64 && "Too many bits for uint64_t"' 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 -gdwarf-4 -g -o /app/output.s -fno-verbose-asm -c --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c2x <source>
1. <source>:2:45: current parser token ','
#0 0x0000000003e6dcc8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3e6dcc8)
#1 0x0000000003e6b984 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3e6b984)
#2 0x0000000003db8298 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x0000701610a42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x0000701610a969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x0000701610a42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x0000701610a287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x0000701610a2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x0000701610a39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x00000000070b3afb clang::Sema::BuildBitIntType(bool, clang::Expr*, clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x70b3afb)
#10 0x00000000070bc613 GetDeclSpecTypeForDeclarator((anonymous namespace)::TypeProcessingState&, clang::TypeSourceInfo*&) (.constprop.0) SemaType.cpp:0:0
#11 0x00000000070cb717 clang::Sema::GetTypeForDeclarator(clang::Declarator&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x70cb717)
#12 0x00000000067c1d7a clang::Sema::ActOnParamDeclarator(clang::Scope*, clang::Declarator&, clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x67c1d7a)
#13 0x000000000647dc74 clang::Parser::ParseParameterDeclarationClause(clang::DeclaratorContext, clang::ParsedAttributes&, llvm::SmallVectorImpl<clang::DeclaratorChunk::ParamInfo>&, clang::SourceLocation&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x647dc74)
#14 0x000000000647eee8 clang::Parser::ParseFunctionDeclarator(clang::Declarator&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x647eee8)
#15 0x00000000064840cf clang::Parser::ParseDirectDeclarator(clang::Declarator&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x64840cf)
#16 0x0000000006470e96 clang::Parser::ParseDeclaratorInternal(clang::Declarator&, void (clang::Parser::*)(clang::Declarator&)) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6470e96)
#17 0x0000000007cfc251 clang::StackExhaustionHandler::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x7cfc251)
#18 0x0000000006473ee7 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+0x6473ee7)
#19 0x000000000643411e clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x643411e)
#20 0x00000000064348d9 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x64348d9)
#21 0x000000000643c0b3 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x643c0b3)
#22 0x000000000643cf8d clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x643cf8d)
#23 0x000000000643d430 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x643d430)
#24 0x000000000642f3e3 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x642f3e3)
#25 0x0000000004830ea8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4830ea8)
#26 0x0000000004af9d95 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4af9d95)
#27 0x0000000004a7d56e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4a7d56e)
#28 0x0000000004be7f2e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4be7f2e)
#29 0x0000000000d535a7 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd535a7)
#30 0x0000000000d4a36a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#31 0x0000000004879539 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
#32 0x0000000003db8744 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3db8744)
#33 0x0000000004879b2f 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
#34 0x000000000483c07d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x483c07d)
#35 0x000000000483d0fe 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+0x483d0fe)
#36 0x0000000004845015 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4845015)
#37 0x0000000000d4f843 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd4f843)
#38 0x0000000000c17374 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xc17374)
#39 0x0000701610a29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#40 0x0000701610a29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#41 0x0000000000d49e15 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd49e15)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
Code:
```c
void foo(_BitInt(66666666666666666666wb) * p, _BitInt(193) * q, _BitInt(257) * r) {
r[0] = (((p[0] + p[1] + p[2]) + q[0] + (p[3] + p[4] + p[5])) + q[1]) + r[1] +
(((p[6] + p[7] + p[8]) + q[2] + (p[9] + p[10] + p[11])) + q[3]) + r[2];
}
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs