| Issue |
107836
|
| Summary |
Clang crashes on incorrect code with -std=c++20
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
Strke
|
Reproducer: https://gcc.godbolt.org/z/P7b5M9WT9 (assertions trunkļ¼
```
#include <iostream>
#include <cstdarg>
int read_int(std::string prompt,...) {
using va_list = std::va_list;
va_list args;
va_start(args, prompt);
auto value = std::stoi(va_arg(args, std::string));
return value;
}
```
get result
```
<source>:7:41: error: second argument to 'va_arg' is of non-POD type 'std::string' (aka 'basic_string<char>') [-Wnon-pod-varargs]
7 | auto value = std::stoi(va_arg(args, std::string));
| ^~~~~~~~~~~
/opt/compiler-explorer/clang-assertions-trunk-20240909/lib/clang/20/include/__stdarg_va_arg.h:20:47: note: expanded from macro 'va_arg'
20 | #define va_arg(ap, type) __builtin_va_arg(ap, type)
| ^~~~
clang++: /root/llvm-project/clang/lib/CodeGen/CGExprAgg.cpp:2085: void clang::CodeGen::CodeGenFunction::EmitAggregateCopy(clang::CodeGen::LValue, clang::CodeGen::LValue, clang::QualType, clang::CodeGen::AggValueSlot::Overlap_t, bool): Assertion `(Record->hasTrivialCopyConstructor() || Record->hasTrivialCopyAssignment() || Record->hasTrivialMoveConstructor() || Record->hasTrivialMoveAssignment() || Record->hasAttr<TrivialABIAttr>() || Record->isUnion()) && "Trying to aggregate-copy a type without a trivial copy/move " "constructor or assignment operator"' 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 --std=c++20 <source>
1. <eof> parser at end of file
2. <source>:3:5: LLVM IR generation of declaration 'read_int'
3. <source>:3:5: Generating code for declaration 'read_int'
#0 0x0000000003b258d8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b258d8)
#1 0x0000000003b2359c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b2359c)
#2 0x0000000003a6c198 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x0000754bbd642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x0000754bbd6969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x0000754bbd642476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x0000754bbd6287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x0000754bbd62871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x0000754bbd639e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x00000000042fd5a7 clang::CodeGen::CodeGenFunction::EmitAggregateCopy(clang::CodeGen::LValue, clang::CodeGen::LValue, clang::QualType, clang::CodeGen::AggValueSlot::Overlap_t, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42fd5a7)
#10 0x00000000042fda71 (anonymous namespace)::AggExprEmitter::EmitCopy(clang::QualType, clang::CodeGen::AggValueSlot const&, clang::CodeGen::AggValueSlot const&) (.isra.0) CGExprAgg.cpp:0:0
#11 0x00000000042fdcfd (anonymous namespace)::AggExprEmitter::EmitFinalDestCopy(clang::QualType, clang::CodeGen::LValue const&, clang::CodeGen::CodeGenFunction::ExprValueKind) CGExprAgg.cpp:0:0
#12 0x00000000042fe7e3 clang::CodeGen::CodeGenFunction::EmitAggFinalDestCopy(clang::QualType, clang::CodeGen::AggValueSlot, clang::CodeGen::LValue const&, clang::CodeGen::CodeGenFunction::ExprValueKind) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42fe7e3)
#13 0x00000000042da680 clang::CodeGen::CodeGenFunction::EmitLoadOfAnyValue(clang::CodeGen::LValue, clang::CodeGen::AggValueSlot, clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42da680)
#14 0x000000000405b009 (anonymous namespace)::X86_64ABIInfo::EmitVAArg(clang::CodeGen::CodeGenFunction&, clang::CodeGen::Address, clang::QualType, clang::CodeGen::AggValueSlot) const X86.cpp:0:0
#15 0x0000000004244508 clang::CodeGen::CodeGenFunction::EmitVAArg(clang::VAArgExpr*, clang::CodeGen::Address&, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4244508)
#16 0x0000000004305f8d (anonymous namespace)::AggExprEmitter::Visit(clang::Expr*) CGExprAgg.cpp:0:0
#17 0x0000000004306830 clang::CodeGen::CodeGenFunction::EmitAggExpr(clang::Expr const*, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4306830)
#18 0x00000000042e9a15 clang::CodeGen::CodeGenFunction::EmitAnyExprToMem(clang::Expr const*, clang::CodeGen::Address, clang::Qualifiers, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42e9a15)
#19 0x00000000042f44c2 clang::CodeGen::CodeGenFunction::EmitMaterializeTemporaryExpr(clang::MaterializeTemporaryExpr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42f44c2)
#20 0x00000000042e4a71 clang::CodeGen::CodeGenFunction::EmitLValueHelper(clang::Expr const*, clang::CodeGen::KnownNonNull_t) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42e4a71)
#21 0x00000000042f2de5 clang::CodeGen::CodeGenFunction::EmitReferenceBindingToExpr(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42f2de5)
#22 0x000000000424ca45 clang::CodeGen::CodeGenFunction::EmitCallArg(clang::CodeGen::CallArgList&, clang::Expr const*, clang::QualType) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x424ca45)
#23 0x0000000004257ea7 clang::CodeGen::CodeGenFunction::EmitCallArgs(clang::CodeGen::CallArgList&, clang::CodeGen::CodeGenFunction::PrototypeWrapper, llvm::iterator_range<clang::Stmt::CastIterator<clang::Expr, clang::Expr const* const, clang::Stmt const* const>>, clang::CodeGen::CodeGenFunction::AbstractCallee, unsigned int, clang::CodeGen::CodeGenFunction::EvaluationOrder) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4257ea7)
#24 0x00000000042f592d clang::CodeGen::CodeGenFunction::EmitCall(clang::QualType, clang::CodeGen::CGCallee const&, clang::CallExpr const*, clang::CodeGen::ReturnValueSlot, llvm::Value*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42f592d)
#25 0x00000000042f7236 clang::CodeGen::CodeGenFunction::EmitCallExpr(clang::CallExpr const*, clang::CodeGen::ReturnValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42f7236)
#26 0x000000000434aad2 (anonymous namespace)::ScalarExprEmitter::VisitCallExpr(clang::CallExpr const*) CGExprScalar.cpp:0:0
#27 0x000000000433ed7b clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#28 0x000000000434bd82 (anonymous namespace)::ScalarExprEmitter::VisitExprWithCleanups(clang::ExprWithCleanups*) CGExprScalar.cpp:0:0
#29 0x000000000433f941 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#30 0x0000000004344a5c clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4344a5c)
#31 0x0000000004296aff clang::CodeGen::CodeGenFunction::EmitScalarInit(clang::Expr const*, clang::ValueDecl const*, clang::CodeGen::LValue, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4296aff)
#32 0x0000000004298334 clang::CodeGen::CodeGenFunction::EmitExprAsInit(clang::Expr const*, clang::ValueDecl const*, clang::CodeGen::LValue, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4298334)
#33 0x00000000042a47f1 clang::CodeGen::CodeGenFunction::EmitAutoVarInit(clang::CodeGen::CodeGenFunction::AutoVarEmission const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42a47f1)
#34 0x00000000042a4db6 clang::CodeGen::CodeGenFunction::EmitVarDecl(clang::VarDecl const&) (.part.0) CGDecl.cpp:0:0
#35 0x00000000042a5006 clang::CodeGen::CodeGenFunction::EmitDecl(clang::Decl const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42a5006)
#36 0x0000000003e78047 clang::CodeGen::CodeGenFunction::EmitDeclStmt(clang::DeclStmt const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e78047)
#37 0x0000000003e8e8c9 clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e8e8c9)
#38 0x0000000003e86535 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e86535)
#39 0x0000000003e8e2e4 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e8e2e4)
#40 0x0000000003ef5fc4 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ef5fc4)
#41 0x0000000003f087df clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f087df)
#42 0x0000000003f6c8fa clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f6c8fa)
#43 0x0000000003f67775 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f67775)
#44 0x0000000003f67d2b clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f67d2b)
#45 0x0000000003f71e63 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#46 0x0000000004473206 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#47 0x0000000004463428 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4463428)
#48 0x00000000065b0ba4 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65b0ba4)
#49 0x0000000004470d68 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4470d68)
#50 0x0000000004702ca9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4702ca9)
#51 0x000000000468655e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x468655e)
#52 0x00000000047ec0ce clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47ec0ce)
#53 0x0000000000cb996f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcb996f)
#54 0x0000000000cb2bba ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#55 0x00000000044b4189 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
#56 0x0000000003a6c644 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a6c644)
#57 0x00000000044b477f 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
#58 0x000000000447a6c5 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x447a6c5)
#59 0x000000000447b12d 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+++0x447b12d)
#60 0x0000000004482d75 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4482d75)
#61 0x0000000000cb6d65 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcb6d65)
#62 0x0000000000b89614 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xb89614)
#63 0x0000754bbd629d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#64 0x0000754bbd629e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#65 0x0000000000cb266e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcb266e)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs