<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/113044>113044</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] Assertion `BitWidth == RHS.BitWidth && "Bit widths must be the same"' failed.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:codegen,
crash-on-valid,
clang:frontend:fuzzer
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
yijan4845
</td>
</tr>
</table>
<pre>
**This testcase is generated by a fuzzer.**
Compiler Explorer: [https://godbolt.org/z/GbhfEYor4](https://godbolt.org/z/GbhfEYor4)
This valid code will crash on Clang Assertion Trunk:
```cpp
void test() {
(void) (__array_rank(int[10]) | 1);
}
```
It seems that this goes back to clang-3.0.
Stack dump:
```
clang++: /root/llvm-project/llvm/include/llvm/ADT/APInt.h:705: llvm::APInt& llvm::APInt::operator|=(const llvm::APInt&): Assertion `BitWidth == RHS.BitWidth && "Bit widths must be the same"' 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 -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics <source>
1. <eof> parser at end of file
2. <source>:1:6: LLVM IR generation of declaration 'test'
3. <source>:1:6: Generating code for declaration 'test'
#0 0x0000000003bb93f8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3bb93f8)
#1 0x0000000003bb70bc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3bb70bc)
#2 0x0000000003b046a8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007d2a46442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007d2a464969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x00007d2a46442476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x00007d2a464287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x00007d2a4642871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x00007d2a46439e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x00000000033ef997 llvm::ConstantFoldBinaryInstruction(unsigned int, llvm::Constant*, llvm::Constant*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x33ef997)
#10 0x0000000000feb5f8 llvm::IRBuilderBase::CreateOr(llvm::Value*, llvm::Value*, llvm::Twine const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xfeb5f8)
#11 0x00000000043ff0cd clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#12 0x00000000043ffc1b (anonymous namespace)::ScalarExprEmitter::Visit(clang::Expr*) CGExprScalar.cpp:0:0
#13 0x00000000043fdf7a clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#14 0x000000000440399c clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x440399c)
#15 0x000000000438d76e clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x438d76e)
#16 0x00000000043b0fc5 clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43b0fc5)
#17 0x0000000004407bff (anonymous namespace)::ScalarExprEmitter::VisitCastExpr(clang::CastExpr*) CGExprScalar.cpp:0:0
#18 0x00000000043fdcc3 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#19 0x000000000440399c clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x440399c)
#20 0x000000000438d76e clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x438d76e)
#21 0x00000000043b0fc5 clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43b0fc5)
#22 0x0000000003f1c5e5 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f1c5e5)
#23 0x0000000003f24304 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f24304)
#24 0x0000000003f8c724 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f8c724)
#25 0x0000000003f9e70c clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f9e70c)
#26 0x00000000040071fa clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x40071fa)
#27 0x0000000004002125 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4002125)
#28 0x000000000400250b clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x400250b)
#29 0x000000000400c943 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#30 0x0000000004531806 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#31 0x00000000045223d8 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45223d8)
#32 0x0000000006677e14 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6677e14)
#33 0x000000000452f368 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x452f368)
#34 0x00000000047ea629 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47ea629)
#35 0x000000000476911e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x476911e)
#36 0x00000000048cfcfe clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x48cfcfe)
#37 0x0000000000cde1ef cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcde1ef)
#38 0x0000000000cd5efa ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#39 0x0000000004573089 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
#40 0x0000000003b04b54 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b04b54)
#41 0x000000000457367f 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
#42 0x0000000004538f7d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4538f7d)
#43 0x000000000453a06d 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+++0x453a06d)
#44 0x0000000004541995 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4541995)
#45 0x0000000000cdb0bf clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcdb0bf)
#46 0x0000000000baa1b4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbaa1b4)
#47 0x00007d2a46429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#48 0x00007d2a46429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#49 0x0000000000cd59ae _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcd59ae)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWt9v3KgW_mvIC5qRjX8_5GHiJN2sutqqibq6TyOM8QxbGyzAadK__grwZIwzSTO9mdVVt0qjmB-H7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