[PATCH] D119095: [clang] Fix redundant functional cast in ConstantExpr
Kim Gräsman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Feb 19 10:17:50 PST 2022
kimgr added a comment.
I can also confirm that `main` and my branch (containing https://reviews.llvm.org/D119477 and https://reviews.llvm.org/D119476) both assert on the same line:
$ cat bug-53244.cc
struct A {
consteval A() {}
A(const A&) = delete;
consteval void f() {}
};
int main() {
A{A{}}.f();
}
$ bin/clang -std=c++20 ../../bug-53244.cc
clang-14: /home/kimgr/code/llvm-project/clang/lib/Sema/SemaExprCXX.cpp:1453: clang::ExprResult clang::Sema::BuildCXXTypeConstructExpr(clang::TypeSourceInfo *, clang::SourceLocation, clang::MultiExprArg, clang::SourceLocation, bool): Assertion `(!ListInitialization || (Exprs.size() == 1 && isa<InitListExpr>(Exprs[0]))) && "List initialization must have initializer list as expression."' 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: /home/kimgr/code/llvm-project/out/main/bin/clang-14 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all --mrelax-relocations -disable-free -clear-ast-before-backend -main-file-name bug-53244.cc -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -fcoverage-compilation-dir=/home/kimgr/code/llvm-project/out/main -resource-dir /home/kimgr/code/llvm-project/out/main/lib/clang/15.0.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/x86_64-linux-gnu/c++/9 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/backward -internal-isystem /home/kimgr/code/llvm-project/out/main/lib/clang/15.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/9/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -std=c++20 -fdeprecated-macro -fdebug-compilation-dir=/home/kimgr/code/llvm-project/out/main -ferror-limit 19 -fgnuc-version=4.2.1 -fno-implicit-modules -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/bug-53244-192e65.o -x c++ ../../bug-53244.cc
1. <eof> parser at end of file
2. ../../bug-53244.cc:7:12: parsing function body 'main'
#0 0x000000000698e43a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/kimgr/code/llvm-project/llvm/lib/Support/Unix/Signals.inc:565:11
#1 0x000000000698e5eb PrintStackTraceSignalHandler(void*) /home/kimgr/code/llvm-project/llvm/lib/Support/Unix/Signals.inc:632:1
#2 0x000000000698cc9a llvm::sys::RunSignalHandlers() /home/kimgr/code/llvm-project/llvm/lib/Support/Signals.cpp:97:5
#3 0x000000000698ed15 SignalHandler(int) /home/kimgr/code/llvm-project/llvm/lib/Support/Unix/Signals.inc:407:1
#4 0x00007f8769c493c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
#5 0x00007f87696dd18b raise /build/glibc-eX1tMB/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
#6 0x00007f87696bc859 abort /build/glibc-eX1tMB/glibc-2.31/stdlib/abort.c:81:7
#7 0x00007f87696bc729 get_sysdep_segment_value /build/glibc-eX1tMB/glibc-2.31/intl/loadmsgcat.c:509:8
#8 0x00007f87696bc729 _nl_load_domain /build/glibc-eX1tMB/glibc-2.31/intl/loadmsgcat.c:970:34
#9 0x00007f87696cdf36 (/lib/x86_64-linux-gnu/libc.so.6+0x36f36)
#10 0x000000000af7d719 clang::Sema::BuildCXXTypeConstructExpr(clang::TypeSourceInfo*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, bool) /home/kimgr/code/llvm-project/clang/lib/Sema/SemaExprCXX.cpp:1454:39
#11 0x000000000ade829d clang::TreeTransform<RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*> > >*>)::ComplexRemove>::RebuildCXXFunctionalCastExpr(clang::TypeSourceInfo*, clang::SourceLocation, clang::Expr*, clang::SourceLocation, bool) /home/kimgr/code/llvm-project/clang/lib/Sema/TreeTransform.h:3019:22
#12 0x000000000adac3d5 clang::TreeTransform<RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*> > >*>)::ComplexRemove>::TransformCXXFunctionalCastExpr(clang::CXXFunctionalCastExpr*) /home/kimgr/code/llvm-project/clang/lib/Sema/TreeTransform.h:11728:23
#13 0x000000000ada4a8f clang::TreeTransform<RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*> > >*>)::ComplexRemove>::TransformExpr(clang::Expr*) /home/kimgr/code/llvm-project/out/main/tools/clang/include/clang/AST/StmtNodes.inc:929:1
#14 0x000000000adcd51c clang::TreeTransform<RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*> > >*>)::ComplexRemove>::TransformExprs(clang::Expr* const*, unsigned int, bool, llvm::SmallVectorImpl<clang::Expr*>&, bool*) /home/kimgr/code/llvm-project/clang/lib/Sema/TreeTransform.h:4047:29
#15 0x000000000adae285 clang::TreeTransform<RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*> > >*>)::ComplexRemove>::TransformInitListExpr(clang::InitListExpr*) /home/kimgr/code/llvm-project/clang/lib/Sema/TreeTransform.h:11246:7
#16 0x000000000ada507e clang::TreeTransform<RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*> > >*>)::ComplexRemove>::TransformExpr(clang::Expr*) /home/kimgr/code/llvm-project/out/main/tools/clang/include/clang/AST/StmtNodes.inc:1147:1
#17 0x000000000adac2d8 clang::TreeTransform<RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*> > >*>)::ComplexRemove>::TransformCXXFunctionalCastExpr(clang::CXXFunctionalCastExpr*) /home/kimgr/code/llvm-project/clang/lib/Sema/TreeTransform.h:11719:20
#18 0x000000000ada4a8f clang::TreeTransform<RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*> > >*>)::ComplexRemove>::TransformExpr(clang::Expr*) /home/kimgr/code/llvm-project/out/main/tools/clang/include/clang/AST/StmtNodes.inc:929:1
#19 0x000000000adafff2 clang::TreeTransform<RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*> > >*>)::ComplexRemove>::TransformMaterializeTemporaryExpr(clang::MaterializeTemporaryExpr*) /home/kimgr/code/llvm-project/clang/lib/Sema/TreeTransform.h:13562:23
#20 0x000000000ada5173 clang::TreeTransform<RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*> > >*>)::ComplexRemove>::TransformExpr(clang::Expr*) /home/kimgr/code/llvm-project/out/main/tools/clang/include/clang/AST/StmtNodes.inc:1177:1
#21 0x000000000adb0257 clang::TreeTransform<RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*> > >*>)::ComplexRemove>::TransformMemberExpr(clang::MemberExpr*) /home/kimgr/code/llvm-project/clang/lib/Sema/TreeTransform.h:10927:34
#22 0x000000000ada51d5 clang::TreeTransform<RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*> > >*>)::ComplexRemove>::TransformExpr(clang::Expr*) /home/kimgr/code/llvm-project/out/main/tools/clang/include/clang/AST/StmtNodes.inc:1189:1
#23 0x000000000adab9b2 clang::TreeTransform<RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*> > >*>)::ComplexRemove>::TransformCallExpr(clang::CallExpr*) /home/kimgr/code/llvm-project/clang/lib/Sema/TreeTransform.h:10891:36
#24 0x000000000adabef5 clang::TreeTransform<RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*> > >*>)::ComplexRemove>::TransformCXXMemberCallExpr(clang::CXXMemberCallExpr*) /home/kimgr/code/llvm-project/clang/lib/Sema/TreeTransform.h:11590:23
#25 0x000000000ada499a clang::TreeTransform<RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*> > >*>)::ComplexRemove>::TransformExpr(clang::Expr*) /home/kimgr/code/llvm-project/out/main/tools/clang/include/clang/AST/StmtNodes.inc:887:1
#26 0x000000000adadce2 clang::TreeTransform<RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*> > >*>)::ComplexRemove>::TransformExprWithCleanups(clang::ExprWithCleanups*) /home/kimgr/code/llvm-project/clang/lib/Sema/TreeTransform.h:12757:23
#27 0x000000000ada4f58 clang::TreeTransform<RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*> > >*>)::ComplexRemove>::TransformExpr(clang::Expr*) /home/kimgr/code/llvm-project/out/main/tools/clang/include/clang/AST/StmtNodes.inc:1107:1
#28 0x000000000ada3933 RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*> > >*>) /home/kimgr/code/llvm-project/clang/lib/Sema/SemaExpr.cpp:16835:32
#29 0x000000000ad90435 HandleImmediateInvocations(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&) /home/kimgr/code/llvm-project/clang/lib/Sema/SemaExpr.cpp:16864:23
#30 0x000000000ad88cf4 clang::Sema::PopExpressionEvaluationContext() /home/kimgr/code/llvm-project/clang/lib/Sema/SemaExpr.cpp:16930:19
#31 0x000000000a91baea ExitFunctionBodyRAII::~ExitFunctionBodyRAII() /home/kimgr/code/llvm-project/clang/lib/Sema/SemaDecl.cpp:14600:3
#32 0x000000000a8f2f2b clang::Sema::ActOnFinishFunctionBody(clang::Decl*, clang::Stmt*, bool) /home/kimgr/code/llvm-project/clang/lib/Sema/SemaDecl.cpp:14983:3
#33 0x000000000a8f1317 clang::Sema::ActOnFinishFunctionBody(clang::Decl*, clang::Stmt*) /home/kimgr/code/llvm-project/clang/lib/Sema/SemaDecl.cpp:14589:3
#34 0x000000000a50505f clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) /home/kimgr/code/llvm-project/clang/lib/Parse/ParseStmt.cpp:2379:18
#35 0x000000000a4c71a0 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) /home/kimgr/code/llvm-project/clang/lib/Parse/Parser.cpp:1378:3
#36 0x000000000a577a20 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*) /home/kimgr/code/llvm-project/clang/lib/Parse/ParseDecl.cpp:2053:27
#37 0x000000000a4c611f clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributesWithRange&, clang::ParsingDeclSpec&, clang::AccessSpecifier) /home/kimgr/code/llvm-project/clang/lib/Parse/Parser.cpp:1138:10
#38 0x000000000a4c57d0 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributesWithRange&, clang::ParsingDeclSpec*, clang::AccessSpecifier) /home/kimgr/code/llvm-project/clang/lib/Parse/Parser.cpp:1154:12
#39 0x000000000a4c50cf clang::Parser::ParseExternalDeclaration(clang::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) /home/kimgr/code/llvm-project/clang/lib/Parse/Parser.cpp:976:12
#40 0x000000000a4c345b clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool) /home/kimgr/code/llvm-project/clang/lib/Parse/Parser.cpp:720:12
#41 0x000000000a4be6e4 clang::ParseAST(clang::Sema&, bool, bool) /home/kimgr/code/llvm-project/clang/lib/Parse/ParseAST.cpp:158:16
#42 0x0000000007bee7bc clang::ASTFrontendAction::ExecuteAction() /home/kimgr/code/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1076:1
#43 0x0000000007dc0d52 clang::CodeGenAction::ExecuteAction() /home/kimgr/code/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1107:5
#44 0x0000000007bee1bc clang::FrontendAction::Execute() /home/kimgr/code/llvm-project/clang/lib/Frontend/FrontendAction.cpp:971:7
#45 0x0000000007b2762c clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /home/kimgr/code/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1036:23
#46 0x0000000007daa037 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /home/kimgr/code/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:263:8
#47 0x000000000499f23d cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /home/kimgr/code/llvm-project/clang/tools/driver/cc1_main.cpp:248:13
#48 0x000000000499278e ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) /home/kimgr/code/llvm-project/clang/tools/driver/driver.cpp:317:5
#49 0x0000000004991821 main /home/kimgr/code/llvm-project/clang/tools/driver/driver.cpp:388:5
#50 0x00007f87696be0b3 __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:342:3
#51 0x000000000499107e _start (/home/kimgr/code/llvm-project/out/main/bin/clang-14+0x499107e)
So I would argue that these two patch sets are independent and solves different problems.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D119095/new/
https://reviews.llvm.org/D119095
More information about the cfe-commits
mailing list