Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

ICE on lambdas returning lambdas 3 deep, when using move or fwd ref #41885

Open Quuxplusone opened 5 years ago

Quuxplusone commented 5 years ago
Bugzilla Link PR42915
Status CONFIRMED
Importance P normal
Reported by llvmbugbjorn@fahller.se
Reported on 2019-08-07 06:36:44 -0700
Last modified on 2021-10-29 07:53:00 -0700
Version 8.0
Hardware PC Linux
CC aaron@aaronballman.com, blitzrakete@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
Fixed by commit(s)
Attachments c.cpp (966 bytes, text/x-c++src)
bt (10294 bytes, text/plain)
c-30b621.cpp (297393 bytes, text/x-c++src)
c-30b621.sh (2219 bytes, application/x-shellscript)
Blocks
Blocked by
See also
Created attachment 22349
Example code causing ICE

The attached file crashes clang++-8.0.0, and trunk (367966).

The crashes are on the lines with a comment '// E'. If those lines are
commented out, it compiles.

There are two ways to make it compile. Remove '= std::move(function)' under the
comment '// 1' or remove the forwarding reference '&&' under the comment '// 2'

godbolt link: https://gcc.godbolt.org/z/DXqN06
Quuxplusone commented 5 years ago

Attached c.cpp (966 bytes, text/x-c++src): Example code causing ICE

Quuxplusone commented 5 years ago

Attached bt (10294 bytes, text/plain): backtrace

Quuxplusone commented 5 years ago

Attached c-30b621.cpp (297393 bytes, text/x-c++src): preprocessed source

Quuxplusone commented 5 years ago

Attached c-30b621.sh (2219 bytes, application/x-shellscript): compiler call

Quuxplusone commented 2 years ago
Can confirm that the crash still happens as of Clang 13 and trunk. Stack trace
is:

PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0.  Program arguments: /opt/compiler-explorer/clang-trunk/bin/clang++ -g -o
/app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-
explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -O3 -std=c++17
<source>
1.  <source>:33:22: current parser token ')'
2.  <source>:9:12: instantiating function definition 'rcurry((lambda at
<source>:18:27))::(anonymous class)::operator()<int>'
3.  <source>:18:27: instantiating function definition 'rcurry((lambda at
<source>:18:27))::(anonymous class)::operator()(int &&)::(anonymous
class)::operator()<int>'
 #0 0x000056024a9878cf PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #1 0x000056024a985790 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3385790)
 #2 0x000056024a8ce5f8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007fc30da333c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
 #4 0x000056024cb38c28 clang::Sema::tryCaptureVariable(clang::VarDecl*, clang::SourceLocation, clang::Sema::TryCaptureKind, clang::SourceLocation, bool, clang::QualType&, clang::QualType&, unsigned int const*) (.constprop.8810) SemaExpr.cpp:0:0
 #5 0x000056024cb3eb0c clang::Sema::BuildDeclRefExpr(clang::ValueDecl*, clang::QualType, clang::ExprValueKind, clang::DeclarationNameInfo const&, clang::NestedNameSpecifierLoc, clang::NamedDecl*, clang::SourceLocation, clang::TemplateArgumentListInfo const*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x553eb0c)
 #6 0x000056024cb3f27d clang::Sema::BuildDeclarationNameExpr(clang::CXXScopeSpec const&, clang::DeclarationNameInfo const&, clang::NamedDecl*, clang::NamedDecl*, clang::TemplateArgumentListInfo const*, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x553f27d)
 #7 0x000056024cf6327b clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformDeclRefExpr(clang::DeclRefExpr*) SemaTemplateInstantiate.cpp:0:0
 #8 0x000056024cf4a758 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) SemaTemplateInstantiate.cpp:0:0
 #9 0x000056024cf51c07 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCallExpr(clang::CallExpr*) SemaTemplateInstantiate.cpp:0:0
#10 0x000056024cf4a643 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*)
SemaTemplateInstantiate.cpp:0:0
#11 0x000056024cf54429 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformType(clang::TypeLocBuilder&,
clang::TypeLoc) SemaTemplateInstantiate.cpp:0:0
#12 0x000056024cf6b17a
clang::Sema::SubstFunctionDeclType(clang::TypeSourceInfo*,
clang::MultiLevelTemplateArgumentList const&, clang::SourceLocation,
clang::DeclarationName, clang::CXXRecordDecl*, clang::Qualifiers)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x596b17a)
#13 0x000056024cf7b470
clang::TemplateDeclInstantiator::SubstFunctionType(clang::FunctionDecl*,
llvm::SmallVectorImpl<clang::ParmVarDecl*>&) (/opt/compiler-explorer/clang-
trunk/bin/clang+++0x597b470)
#14 0x000056024cfb6e66
clang::TemplateDeclInstantiator::VisitCXXMethodDecl(clang::CXXMethodDecl*,
clang::TemplateParameterList*,
llvm::Optional<clang::ASTTemplateArgumentListInfo const*>,
clang::TemplateDeclInstantiator::RewriteKind) (/opt/compiler-explorer/clang-
trunk/bin/clang+++0x59b6e66)
#15 0x000056024cfb8724 void llvm::function_ref<void
()>::callback_fn<clang::Sema::SubstDecl(clang::Decl*, clang::DeclContext*,
clang::MultiLevelTemplateArgumentList const&)::'lambda'()>(long)
SemaTemplateInstantiateDecl.cpp:0:0
#16 0x000056024c885c5f
clang::Sema::runWithSufficientStackSpace(clang::SourceLocation,
llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-
trunk/bin/clang+++0x5285c5f)
#17 0x000056024cf7af53 clang::Sema::SubstDecl(clang::Decl*,
clang::DeclContext*, clang::MultiLevelTemplateArgumentList const&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x597af53)
#18 0x000056024cf1e2af
clang::Sema::FinishTemplateArgumentDeduction(clang::FunctionTemplateDecl*,
llvm::SmallVectorImpl<clang::DeducedTemplateArgument>&, unsigned int,
clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&,
llvm::SmallVectorImpl<clang::Sema::OriginalCallArg> const*, bool,
llvm::function_ref<bool ()>) (/opt/compiler-explorer/clang-
trunk/bin/clang+++0x591e2af)
#19 0x000056024cf1fdae void llvm::function_ref<void
()>::callback_fn<clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*,
clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>,
clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, bool,
llvm::function_ref<bool (llvm::ArrayRef<clang::QualType>)>)::'lambda1'()>(long)
SemaTemplateDeduction.cpp:0:0
#20 0x000056024c885c5f
clang::Sema::runWithSufficientStackSpace(clang::SourceLocation,
llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-
trunk/bin/clang+++0x5285c5f)
#21 0x000056024cf2bb64
clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*,
clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>,
clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, bool,
llvm::function_ref<bool (llvm::ArrayRef<clang::QualType>)>) (/opt/compiler-
explorer/clang-trunk/bin/clang+++0x592bb64)
#22 0x000056024cdf0f7c
clang::Sema::AddMethodTemplateCandidate(clang::FunctionTemplateDecl*,
clang::DeclAccessPair, clang::CXXRecordDecl*, clang::TemplateArgumentListInfo*,
clang::QualType, clang::Expr::Classification, llvm::ArrayRef<clang::Expr*>,
clang::OverloadCandidateSet&, bool, bool, clang::OverloadCandidateParamOrder)
(.constprop.1361) SemaOverload.cpp:0:0
#23 0x000056024cdf15af clang::Sema::AddMethodCandidate(clang::DeclAccessPair,
clang::QualType, clang::Expr::Classification, llvm::ArrayRef<clang::Expr*>,
clang::OverloadCandidateSet&, bool, clang::OverloadCandidateParamOrder)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x57f15af)
#24 0x000056024cdfb770 clang::Sema::BuildCallToObjectOfClassType(clang::Scope*,
clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>,
clang::SourceLocation) (/opt/compiler-explorer/clang-
trunk/bin/clang+++0x57fb770)
#25 0x000056024cb63844 clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*,
clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>,
clang::SourceLocation, clang::Expr*, bool, bool) (/opt/compiler-explorer/clang-
trunk/bin/clang+++0x5563844)
#26 0x000056024cb680e4 clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*,
clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>,
clang::SourceLocation, clang::Expr*) (/opt/compiler-explorer/clang-
trunk/bin/clang+++0x55680e4)
#27 0x000056024cf51d0e clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformCallExpr(clang::CallExpr*)
SemaTemplateInstantiate.cpp:0:0
#28 0x000056024cf4a643 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*)
SemaTemplateInstantiate.cpp:0:0
#29 0x000056024cf4b51b clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformInitializer(clang::Expr*, bool)
SemaTemplateInstantiate.cpp:0:0
#30 0x000056024cf4c817 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformReturnStmt(clang::ReturnStmt*)
SemaTemplateInstantiate.cpp:0:0
#31 0x000056024cf73113 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*,
bool) SemaTemplateInstantiate.cpp:0:0
#32 0x000056024cf7772a clang::Sema::SubstStmt(clang::Stmt*,
clang::MultiLevelTemplateArgumentList const&) (/opt/compiler-explorer/clang-
trunk/bin/clang+++0x597772a)
#33 0x000056024cfaed77
clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation,
clang::FunctionDecl*, bool, bool, bool) (/opt/compiler-explorer/clang-
trunk/bin/clang+++0x59aed77)
#34 0x000056024cfaddb2 clang::Sema::PerformPendingInstantiations(bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x59addb2)
#35 0x000056024cfaebd5
clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation,
clang::FunctionDecl*, bool, bool, bool) (/opt/compiler-explorer/clang-
trunk/bin/clang+++0x59aebd5)
#36 0x000056024c885c5f
clang::Sema::runWithSufficientStackSpace(clang::SourceLocation,
llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-
trunk/bin/clang+++0x5285c5f)
#37 0x000056024cee7ffd clang::Sema::DeduceReturnType(clang::FunctionDecl*,
clang::SourceLocation, bool) (/opt/compiler-explorer/clang-
trunk/bin/clang+++0x58e7ffd)
#38 0x000056024cb29901 clang::Sema::DiagnoseUseOfDecl(clang::NamedDecl*,
llvm::ArrayRef<clang::SourceLocation>, clang::ObjCInterfaceDecl const*, bool,
bool, clang::ObjCInterfaceDecl*) (/opt/compiler-explorer/clang-
trunk/bin/clang+++0x5529901)
#39 0x000056024cdc43bf CreateFunctionRefExpr(clang::Sema&,
clang::FunctionDecl*, clang::NamedDecl*, clang::Expr const*, bool,
clang::SourceLocation, clang::DeclarationNameLoc const&) SemaOverload.cpp:0:0
#40 0x000056024cdfba6f clang::Sema::BuildCallToObjectOfClassType(clang::Scope*,
clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>,
clang::SourceLocation) (/opt/compiler-explorer/clang-
trunk/bin/clang+++0x57fba6f)
#41 0x000056024cb63844 clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*,
clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>,
clang::SourceLocation, clang::Expr*, bool, bool) (/opt/compiler-explorer/clang-
trunk/bin/clang+++0x5563844)
#42 0x000056024cb680e4 clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*,
clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>,
clang::SourceLocation, clang::Expr*) (/opt/compiler-explorer/clang-
trunk/bin/clang+++0x55680e4)
#43 0x000056024c7ca178
clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*,
true>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x51ca178)
#44 0x000056024c7c4217
clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&,
clang::Parser::TypeCastState, bool, bool*) (/opt/compiler-explorer/clang-
trunk/bin/clang+++0x51c4217)
#45 0x000056024c7c6c36
clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool,
clang::Parser::TypeCastState, bool, bool*) (/opt/compiler-explorer/clang-
trunk/bin/clang+++0x51c6c36)
#46 0x000056024c7c6cc8
clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x51c6cc8)
#47 0x000056024c7df77d clang::Parser::ParseBraceInitializer() (/opt/compiler-
explorer/clang-trunk/bin/clang+++0x51df77d)
#48 0x000056024c792ae4
clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x5192ae4)
#49 0x000056024c7a33d5 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x51a33d5)
#50 0x000056024c775559
clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-
trunk/bin/clang+++0x5175559)
#51 0x000056024c775c61
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier) (.part.280) Parser.cpp:0:0
#52 0x000056024c77bb89
clang::Parser::ParseExternalDeclaration(clang::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-
trunk/bin/clang+++0x517bb89)
#53 0x000056024c77cfa9
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x517cfa9)
#54 0x000056024c770809 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-
explorer/clang-trunk/bin/clang+++0x5170809)
#55 0x000056024b926ab2 clang::CodeGenAction::ExecuteAction() (/opt/compiler-
explorer/clang-trunk/bin/clang+++0x4326ab2)
#56 0x000056024b2b4b71 clang::FrontendAction::Execute() (/opt/compiler-
explorer/clang-trunk/bin/clang+++0x3cb4b71)
#57 0x000056024b250d12
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-
explorer/clang-trunk/bin/clang+++0x3c50d12)
#58 0x000056024b383023
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-
explorer/clang-trunk/bin/clang+++0x3d83023)
#59 0x000056024868ce3c cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x108ce3c)
#60 0x000056024868904d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
driver.cpp:0:0
#61 0x000056024b0faeb5 void llvm::function_ref<void
()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#62 0x000056024a8cebe3
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x32cebe3)
#63 0x000056024b0fcf6e
clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >*, bool*) const (/opt/compiler-explorer/clang-
trunk/bin/clang+++0x3afcf6e)
#64 0x000056024b0d26ea
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const (/opt/compiler-explorer/clang-
trunk/bin/clang+++0x3ad26ea)
#65 0x000056024b0d322f
clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3ad322f)
#66 0x000056024b0db6a5
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3adb6a5)
#67 0x000056024859c70e main (/opt/compiler-explorer/clang-
trunk/bin/clang+++0xf9c70e)
#68 0x00007fc30d4e30b3 __libc_start_main (/lib/x86_64-linux-
gnu/libc.so.6+0x270b3)
#69 0x0000560248688bca _start (/opt/compiler-explorer/clang-
trunk/bin/clang+++0x1088bca)
clang-14: error: clang frontend command failed with exit code 139 (use -v to
see invocation)
Compiler returned: 139