Skip to content

Clang assertion failure in CastInst::Create() with "Invalid cast!" when generating code for function with builtin expression #144771

@kappnkappn

Description

@kappnkappn

Compiler explorer: https://godbolt.org/z/r55hMorrY
generated by fuzzer

Code:

int v;

__attribute__((noinline, noclone)) void bar(void) { v++; }

#define T(n, t1, t2, tr, v1, v2, vr, b, o)                                     \
  __attribute__((noinline, noclone)) tr t##n##_1##b(t1 x, t2 y) {              \
    tr r;                                                                      \
    if (__builtin_##b##_overflow(x, y, &r))                                    \
      bar();                                                                   \
    return r;                                                                  \
  }                                                                            \
                                                                               \
  __attribute__((noinline, noclone)) tr t##n##_3##b(t2 y) {                    \
    tr r;                                                                      \
    if (__builtin_##b##_overflow((v1), y, &r))                             \
      bar();                                                                   \
    return r;                                                                  \
  }                                                                            \
                                                                               \
  __attribute__((noinline, noclone)) tr t##n##_4##b(t1 x) {                    \
    t2 y = (v2);                                                               \
    tr r;                                                                      \
    if (__builtin_##b##_overflow(x, y, &r))                                    \
      bar();                                                                   \
    return r;                                                                  \
  }                                                                            \
                                                                                                                                                                                                                                                           

#define ST(n, t, v1, v2, vr, b, o) T(n, t, t, t, v1, v2, vr, b, o)

#define TESTS(type, min, max)                                                  \
  ST(171, unsigned type, max, 3, 3 * (unsigned type)max, U(u, mul), 1)         


#define U(s, op) op
TESTS(_BitInt(119), (-332306998946228968225951765070086143wb - 1),
      332306998946228968225951765070086143wb)

Stack trace:

clang: /root/llvm-project/llvm/lib/IR/Instructions.cpp:3033: static llvm::CastInst* llvm::CastInst::Create(llvm::Instruction::CastOps, llvm::Value*, llvm::Type*, const llvm::Twine&, llvm::InsertPosition): Assertion `castIsValid(op, S, Ty) && "Invalid cast!"' 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 <source>
1.	<source>:36:1 <Spelling=<source>:20:3>: current parser token '__attribute__'
2.	<source>:36:1 <Spelling=<scratch space>:11:1>: LLVM IR generation of declaration 't171_3mul'
3.	<source>:36:1 <Spelling=<scratch space>:11:1>: Generating code for declaration 't171_3mul'
 #0 0x0000000003fb0f48 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fb0f48)
 #1 0x0000000003faebd4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3faebd4)
 #2 0x0000000003ef3728 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x0000772769842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007727698969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x0000772769842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x00007727698287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x000077276982871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x0000772769839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x00000000038b5c54 (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x38b5c54)
#10 0x0000000000ff09b5 llvm::IRBuilderBase::CreateTrunc(llvm::Value*, llvm::Type*, llvm::Twine const&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xff09b5)
#11 0x0000000004847ac3 clang::CodeGen::CodeGenFunction::EmitBuiltinExpr(clang::GlobalDecl, unsigned int, clang::CallExpr const*, clang::CodeGen::ReturnValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4847ac3)
#12 0x000000000432050e clang::CodeGen::CodeGenFunction::EmitCallExpr(clang::CallExpr const*, clang::CodeGen::ReturnValueSlot, llvm::CallBase**) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x432050e)
#13 0x0000000004392df4 (anonymous namespace)::ScalarExprEmitter::VisitCallExpr(clang::CallExpr const*) CGExprScalar.cpp:0:0
#14 0x0000000004385c20 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#15 0x000000000438bb9c clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x438bb9c)
#16 0x00000000042ef36d clang::CodeGen::CodeGenFunction::EvaluateExprAsBool(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x42ef36d)
#17 0x000000000450ab4c clang::CodeGen::CodeGenFunction::EmitBranchOnBoolExpr(clang::Expr const*, llvm::BasicBlock*, llvm::BasicBlock*, unsigned long, clang::Stmt::Likelihood, clang::Expr const*, clang::VarDecl const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x450ab4c)
#18 0x000000000449f7b5 clang::CodeGen::CodeGenFunction::EmitIfStmt(clang::IfStmt const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x449f7b5)
#19 0x00000000044982ae clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x44982ae)
#20 0x00000000044a018c clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x44a018c)
#21 0x000000000450640e clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x450640e)
#22 0x0000000004519714 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4519714)
#23 0x0000000004583cad clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4583cad)
#24 0x000000000457eca4 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x457eca4)
#25 0x000000000457f353 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x457f353)
#26 0x0000000004589ef3 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#27 0x000000000496e0f6 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#28 0x000000000495dbd4 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x495dbd4)
#29 0x0000000006664364 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6664364)
#30 0x000000000496a288 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x496a288)
#31 0x0000000004c640f5 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4c640f5)
#32 0x0000000004be13fe clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4be13fe)
#33 0x0000000004d565e9 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4d565e9)
#34 0x0000000000d821df cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd821df)
#35 0x0000000000d78dea ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#36 0x00000000049d0d99 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
#37 0x0000000003ef3bc4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3ef3bc4)
#38 0x00000000049d13af 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
#39 0x000000000499344d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x499344d)
#40 0x00000000049944de 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+0x49944de)
#41 0x000000000499c1e5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x499c1e5)
#42 0x0000000000d7e6ef clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd7e6ef)
#43 0x0000000000c3c994 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xc3c994)
#44 0x0000772769829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#45 0x0000772769829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#46 0x0000000000d78895 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd78895)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134

Activity

added
clangClang issues not falling into any other category
on Jun 18, 2025
added
clang:codegenIR generation bugs: mangling, exceptions, etc.
crashPrefer [crash-on-valid] or [crash-on-invalid]
and removed
clangClang issues not falling into any other category
on Jun 18, 2025
llvmbot

llvmbot commented on Jun 18, 2025

@llvmbot
Member

@llvm/issue-subscribers-clang-codegen

Author: None (kappnkappn)

Compiler explorer: [https://godbolt.org/z/r55hMorrY](https://godbolt.org/z/r55hMorrY) generated by fuzzer

Code:

int v;

__attribute__((noinline, noclone)) void bar(void) { v++; }

#define T(n, t1, t2, tr, v1, v2, vr, b, o)                                     \
  __attribute__((noinline, noclone)) tr t##n##_1##b(t1 x, t2 y) {              \
    tr r;                                                                      \
    if (__builtin_##b##_overflow(x, y, &amp;r))                                    \
      bar();                                                                   \
    return r;                                                                  \
  }                                                                            \
                                                                               \
  __attribute__((noinline, noclone)) tr t##n##_3##b(t2 y) {                    \
    tr r;                                                                      \
    if (__builtin_##b##_overflow((v1), y, &amp;r))                             \
      bar();                                                                   \
    return r;                                                                  \
  }                                                                            \
                                                                               \
  __attribute__((noinline, noclone)) tr t##n##_4##b(t1 x) {                    \
    t2 y = (v2);                                                               \
    tr r;                                                                      \
    if (__builtin_##b##_overflow(x, y, &amp;r))                                    \
      bar();                                                                   \
    return r;                                                                  \
  }                                                                            \
                                                                                                                                                                                                                                                           

#define ST(n, t, v1, v2, vr, b, o) T(n, t, t, t, v1, v2, vr, b, o)

#define TESTS(type, min, max)                                                  \
  ST(171, unsigned type, max, 3, 3 * (unsigned type)max, U(u, mul), 1)         


#define U(s, op) op
TESTS(_BitInt(119), (-332306998946228968225951765070086143wb - 1),
      332306998946228968225951765070086143wb)

Stack trace:

clang: /root/llvm-project/llvm/lib/IR/Instructions.cpp:3033: static llvm::CastInst* llvm::CastInst::Create(llvm::Instruction::CastOps, llvm::Value*, llvm::Type*, const llvm::Twine&amp;, llvm::InsertPosition): Assertion `castIsValid(op, S, Ty) &amp;&amp; "Invalid cast!"' 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 &lt;source&gt;
1.	&lt;source&gt;:36:1 &lt;Spelling=&lt;source&gt;:20:3&gt;: current parser token '__attribute__'
2.	&lt;source&gt;:36:1 &lt;Spelling=&lt;scratch space&gt;:11:1&gt;: LLVM IR generation of declaration 't171_3mul'
3.	&lt;source&gt;:36:1 &lt;Spelling=&lt;scratch space&gt;:11:1&gt;: Generating code for declaration 't171_3mul'
 #<!-- -->0 0x0000000003fb0f48 llvm::sys::PrintStackTrace(llvm::raw_ostream&amp;, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fb0f48)
 #<!-- -->1 0x0000000003faebd4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3faebd4)
 #<!-- -->2 0x0000000003ef3728 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #<!-- -->3 0x0000772769842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #<!-- -->4 0x00007727698969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #<!-- -->5 0x0000772769842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #<!-- -->6 0x00007727698287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #<!-- -->7 0x000077276982871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #<!-- -->8 0x0000772769839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #<!-- -->9 0x00000000038b5c54 (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x38b5c54)
#<!-- -->10 0x0000000000ff09b5 llvm::IRBuilderBase::CreateTrunc(llvm::Value*, llvm::Type*, llvm::Twine const&amp;, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xff09b5)
#<!-- -->11 0x0000000004847ac3 clang::CodeGen::CodeGenFunction::EmitBuiltinExpr(clang::GlobalDecl, unsigned int, clang::CallExpr const*, clang::CodeGen::ReturnValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4847ac3)
#<!-- -->12 0x000000000432050e clang::CodeGen::CodeGenFunction::EmitCallExpr(clang::CallExpr const*, clang::CodeGen::ReturnValueSlot, llvm::CallBase**) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x432050e)
#<!-- -->13 0x0000000004392df4 (anonymous namespace)::ScalarExprEmitter::VisitCallExpr(clang::CallExpr const*) CGExprScalar.cpp:0:0
#<!-- -->14 0x0000000004385c20 clang::StmtVisitorBase&lt;std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*&gt;::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#<!-- -->15 0x000000000438bb9c clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x438bb9c)
#<!-- -->16 0x00000000042ef36d clang::CodeGen::CodeGenFunction::EvaluateExprAsBool(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x42ef36d)
#<!-- -->17 0x000000000450ab4c clang::CodeGen::CodeGenFunction::EmitBranchOnBoolExpr(clang::Expr const*, llvm::BasicBlock*, llvm::BasicBlock*, unsigned long, clang::Stmt::Likelihood, clang::Expr const*, clang::VarDecl const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x450ab4c)
#<!-- -->18 0x000000000449f7b5 clang::CodeGen::CodeGenFunction::EmitIfStmt(clang::IfStmt const&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x449f7b5)
#<!-- -->19 0x00000000044982ae clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef&lt;clang::Attr const*&gt;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x44982ae)
#<!-- -->20 0x00000000044a018c clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&amp;, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x44a018c)
#<!-- -->21 0x000000000450640e clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x450640e)
#<!-- -->22 0x0000000004519714 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4519714)
#<!-- -->23 0x0000000004583cad clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4583cad)
#<!-- -->24 0x000000000457eca4 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x457eca4)
#<!-- -->25 0x000000000457f353 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x457f353)
#<!-- -->26 0x0000000004589ef3 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#<!-- -->27 0x000000000496e0f6 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#<!-- -->28 0x000000000495dbd4 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x495dbd4)
#<!-- -->29 0x0000000006664364 clang::ParseAST(clang::Sema&amp;, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6664364)
#<!-- -->30 0x000000000496a288 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x496a288)
#<!-- -->31 0x0000000004c640f5 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4c640f5)
#<!-- -->32 0x0000000004be13fe clang::CompilerInstance::ExecuteAction(clang::FrontendAction&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4be13fe)
#<!-- -->33 0x0000000004d565e9 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4d565e9)
#<!-- -->34 0x0000000000d821df cc1_main(llvm::ArrayRef&lt;char const*&gt;, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd821df)
#<!-- -->35 0x0000000000d78dea ExecuteCC1Tool(llvm::SmallVectorImpl&lt;char const*&gt;&amp;, llvm::ToolContext const&amp;) driver.cpp:0:0
#<!-- -->36 0x00000000049d0d99 void llvm::function_ref&lt;void ()&gt;::callback_fn&lt;clang::driver::CC1Command::Execute(llvm::ArrayRef&lt;std::optional&lt;llvm::StringRef&gt;&gt;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt;&gt;*, bool*) const::'lambda'()&gt;(long) Job.cpp:0:0
#<!-- -->37 0x0000000003ef3bc4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref&lt;void ()&gt;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3ef3bc4)
#<!-- -->38 0x00000000049d13af clang::driver::CC1Command::Execute(llvm::ArrayRef&lt;std::optional&lt;llvm::StringRef&gt;&gt;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt;&gt;*, bool*) const (.part.0) Job.cpp:0:0
#<!-- -->39 0x000000000499344d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&amp;, clang::driver::Command const*&amp;, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x499344d)
#<!-- -->40 0x00000000049944de clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&amp;, llvm::SmallVectorImpl&lt;std::pair&lt;int, clang::driver::Command const*&gt;&gt;&amp;, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x49944de)
#<!-- -->41 0x000000000499c1e5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&amp;, llvm::SmallVectorImpl&lt;std::pair&lt;int, clang::driver::Command const*&gt;&gt;&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x499c1e5)
#<!-- -->42 0x0000000000d7e6ef clang_main(int, char**, llvm::ToolContext const&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd7e6ef)
#<!-- -->43 0x0000000000c3c994 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xc3c994)
#<!-- -->44 0x0000772769829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#<!-- -->45 0x0000772769829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#<!-- -->46 0x0000000000d78895 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd78895)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
shafik

shafik commented on Jun 18, 2025

@shafik
Collaborator

A couple of tips, we like to know how far back the bug goes, since godbolt does not have assertion build for C going back you can use C++ w/ -x c, although sometimes the same code crashes in both C and C++.

Also no point is executing the code in the example if it crashes during complilation.

Looks like this started with clang-19: https://godbolt.org/z/cdxvq39TT

shafik

shafik commented on Jun 19, 2025

@shafik
Collaborator

@Fznamznon @rjmccall git bisect points to 9ad72df

Fznamznon

Fznamznon commented on Jun 23, 2025

@Fznamznon
Contributor

Reduced


void foo (unsigned _BitInt(119) y) {
    unsigned _BitInt(119) r; 

  __builtin_mul_overflow((332306998946228968225951765070086143wb), y, &r);
}

self-assigned this
on Jun 23, 2025

5 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

clang:codegenIR generation bugs: mangling, exceptions, etc.confirmedVerified by a second partycrashPrefer [crash-on-valid] or [crash-on-invalid]generated by fuzzerregression:19Regression in 19 release

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @AaronBallman@shafik@EugeneZelenko@Fznamznon@llvmbot

    Issue actions

      Clang assertion failure in CastInst::Create() with "Invalid cast!" when generating code for function with builtin expression · Issue #144771 · llvm/llvm-project