Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clang crash in CodeGen #62945

Closed
HerrCai0907 opened this issue May 25, 2023 · 4 comments · Fixed by #65918
Closed

clang crash in CodeGen #62945

HerrCai0907 opened this issue May 25, 2023 · 4 comments · Fixed by #65918

Comments

@HerrCai0907
Copy link
Contributor

HerrCai0907 commented May 25, 2023

This code can be compiled by gcc but crash clang

void f(int (&&)[]);
void foo(int a) { f({a}); }

https://godbolt.org/z/3qb6x3Y48

error stack

Assertion:

clang++: /root/llvm-project/clang/lib/CodeGen/CGCall.cpp:4372: 
void clang::CodeGen::CodeGenFunction::EmitCallArgs(clang::CodeGen::CallArgList&, clang::CodeGen::CodeGenFunction::PrototypeWrapper, llvm::iterator_range<clang::Stmt::CastIterator<clang::Expr, const clang::Expr* const, const clang::Stmt* const> >, clang::CodeGen::CodeGenFunction::AbstractCallee, unsigned int, clang::CodeGen::CodeGenFunction::EvaluationOrder): 
Assertion `(isGenericMethod || Ty->isVariablyModifiedType() || Ty.getNonReferenceType()->isObjCRetainableType() || getContext() .getCanonicalType(Ty.getNonReferenceType()) .getTypePtr() == getContext().getCanonicalType((*Arg)->getType()).getTypePtr()) && "type mismatch in call argument!"' failed.

Backtrace

8  clang-17                 0x0000000104b9fe48 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) + 996
9  clang-17                 0x0000000104dab534 clang::CodeGen::CodeGenFunction::EmitCall(clang::QualType, clang::CodeGen::CGCallee const&, clang::CallExpr const*, clang::CodeGen::ReturnValueSlot, llvm::Value*) + 3004
10 clang-17                 0x0000000104daa3e4 clang::CodeGen::CodeGenFunction::EmitCallExpr(clang::CallExpr const*, clang::CodeGen::ReturnValueSlot) + 632
11 clang-17                 0x0000000104e23130 (anonymous namespace)::ScalarExprEmitter::VisitCallExpr(clang::CallExpr const*) + 176
12 clang-17                 0x0000000104e1d08c clang::StmtVisitorBase<std::__1::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) + 4172
13 clang-17                 0x0000000104e13ea0 (anonymous namespace)::ScalarExprEmitter::Visit(clang::Expr*) + 60
14 clang-17                 0x0000000104e24384 (anonymous namespace)::ScalarExprEmitter::VisitExprWithCleanups(clang::ExprWithCleanups*) + 80
15 clang-17                 0x0000000104e1d30c clang::StmtVisitorBase<std::__1::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) + 4812
16 clang-17                 0x0000000104e13ea0 (anonymous namespace)::ScalarExprEmitter::Visit(clang::Expr*) + 60
17 clang-17                 0x0000000104e13de8 clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) + 204
18 clang-17                 0x0000000104d8ce9c clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) + 148
19 clang-17                 0x0000000104d8cd68 clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) + 108
20 clang-17                 0x0000000104fd2984 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) + 632
21 clang-17                 0x0000000104fdcbf4 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) + 844
22 clang-17                 0x00000001050a37d0 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) + 128
23 clang-17                 0x00000001050a4420 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) + 1648
24 clang-17                 0x00000001050d9c5c clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) + 476
25 clang-17                 0x00000001050cfc74 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) + 648
26 clang-17                 0x00000001050d52dc clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) + 1748
27 clang-17                 0x00000001050ce318 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) + 232
28 clang-17                 0x00000001052eb520 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) + 164
@HerrCai0907 HerrCai0907 added clang Clang issues not falling into any other category crash-on-valid labels May 25, 2023
@EugeneZelenko EugeneZelenko added clang:codegen and removed clang Clang issues not falling into any other category labels May 25, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented May 25, 2023

@llvm/issue-subscribers-clang-codegen

@HerrCai0907 HerrCai0907 self-assigned this May 25, 2023
@shafik
Copy link
Collaborator

shafik commented May 25, 2023

@rnk this assertion looks like it was added by you here: https://reviews.llvm.org/D92883

Is this code expected to trip this assertion or does it need adjusting?

@HerrCai0907
Copy link
Contributor Author

candidate https://reviews.llvm.org/D151515

I think it should be accepted acc. p0388 conversions to unbounded array

@shafik
Copy link
Collaborator

shafik commented Jun 1, 2023

I wonder what does your patch do w/ #63057

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants