<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - ICE produced by invokation of c++2a-style templated lambda"
   href="https://bugs.llvm.org/show_bug.cgi?id=43022">43022</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>ICE produced by invokation of c++2a-style templated lambda
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++2a
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>l.lehning@web.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=22384" name="attach_22384" title="Problematic code snippet">attachment 22384</a> <a href="attachment.cgi?id=22384&action=edit" title="Problematic code snippet">[details]</a></span>
Problematic code snippet

I've encountered a segmentation fault in clang trying to implement a compile
time type iteration higher order function using the c++2a lambda extensions to
pass the type and index of the type in the tuple.

The problematic code is attached as a picture for better readability and the
stacktrace is below:



Stack dump:

0.      Program arguments:
/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10 -cc1 -triple
x86_64-unknown-linux-gnu -S -disable-free -disable-llvm-verifier
-discard-value-names -main-file-name example.cpp -mrelocation-model static
-mthread-model posix -mframe-pointer=none -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64
-dwarf-column-info -debug-info-kind=limited -dwarf-version=4
-debugger-tuning=gdb -coverage-notes-file /home/ubuntu/./output.gcno
-resource-dir /opt/compiler-explorer/clang-trunk-20190816/lib/clang/10.0.0
-internal-isystem
/opt/compiler-explorer/clang-trunk-20190816/bin/../include/c++/v1
-internal-isystem /usr/local/include -internal-isystem
/opt/compiler-explorer/clang-trunk-20190816/lib/clang/10.0.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include -O3
--std=c++2a -fdeprecated-macro -fdebug-compilation-dir /home/ubuntu
-ferror-limit 19 -fmessage-length 0 -fno-implicit-modules -fobjc-runtime=gcc
-fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics
-vectorize-loops -vectorize-slp -mllvm --x86-asm-syntax=intel -faddrsig -o
./output.s -x c++ <source> 

1.      <source>:20:6: current parser token ')'

2.      <source>:17:20: parsing function body 'main'

3.      <source>:17:20: in compound statement ('{}')

4.      <source>:8:16: instantiating function definition 'enum_tuple<int, bool,
char, (lambda at <source>:18:33)>'

5.      <source>:12:12: instantiating function definition 'enum_tuple((lambda
at <source>:18:33) &&)::(anonymous class)::operator()<0, 1, 2>'

6.      <source>:18:33: instantiating class definition ''

 #0 0x000056211bd729da llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x28339da)

 #1 0x000056211bd70774 llvm::sys::RunSignalHandlers()
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x2831774)

 #2 0x000056211bd708b2 SignalHandler(int)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x28318b2)

 #3 0x00007faf64b72890 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)

 #4 0x000056211d974d71
clang::Sema::SubstFunctionDeclType(clang::TypeSourceInfo*,
clang::MultiLevelTemplateArgumentList const&, clang::SourceLocation,
clang::DeclarationName, clang::CXXRecordDecl*, clang::Qualifiers)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x4435d71)

 #5 0x000056211d984454
clang::TemplateDeclInstantiator::SubstFunctionType(clang::FunctionDecl*,
llvm::SmallVectorImpl<clang::ParmVarDecl*>&)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x4445454)

 #6 0x000056211d9959b7
clang::TemplateDeclInstantiator::VisitCXXMethodDecl(clang::CXXMethodDecl*,
clang::TemplateParameterList*,
llvm::Optional<clang::ASTTemplateArgumentListInfo const*>)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x44569b7)

 #7 0x000056211d96dea1 clang::Sema::InstantiateClass(clang::SourceLocation,
clang::CXXRecordDecl*, clang::CXXRecordDecl*,
clang::MultiLevelTemplateArgumentList const&,
clang::TemplateSpecializationKind, bool)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x442eea1)

 #8 0x000056211d992592
clang::TemplateDeclInstantiator::VisitCXXRecordDecl(clang::CXXRecordDecl*)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x4453592)

 #9 0x000056211d992b4d clang::Sema::SubstDecl(clang::Decl*,
clang::DeclContext*, clang::MultiLevelTemplateArgumentList const&)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x4453b4d)

#10 0x000056211d98c62b clang::Sema::FindInstantiatedDecl(clang::SourceLocation,
clang::NamedDecl*, clang::MultiLevelTemplateArgumentList const&, bool)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x444d62b)

#11 0x000056211d9501db (anonymous
namespace)::TemplateInstantiator::TransformDecl(clang::SourceLocation,
clang::Decl*)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x44111db)

#12 0x000056211d9710f4 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformUnresolvedMemberExpr(clang::UnresolvedMemberExpr*)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x44320f4)

#13 0x000056211d95bdcb clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x441cdcb)

#14 0x000056211d961360 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformCallExpr(clang::CallExpr*)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x4422360)

#15 0x000056211d95ba5b clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x441ca5b)

#16 0x000056211d9797a2 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformCXXNamedCastExpr(clang::CXXNamedCastExpr*)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x443a7a2)

#17 0x000056211d95bac9 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x441cac9)

#18 0x000056211d960f00 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformCXXFoldExpr(clang::CXXFoldExpr*)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x4421f00)

#19 0x000056211d95b980 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x441c980)

#20 0x000056211d97c1b0 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformStmt(clang::Stmt*,
clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::StmtDiscardKind)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x443d1b0)

#21 0x000056211d980ab0 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x4441ab0)

#22 0x000056211d9809ba clang::Sema::SubstStmt(clang::Stmt*,
clang::MultiLevelTemplateArgumentList const&)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x44419ba)

#23 0x000056211d99508c
clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation,
clang::FunctionDecl*, bool, bool, bool)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x445608c)

#24 0x000056211d91d959 clang::Sema::DeduceReturnType(clang::FunctionDecl*,
clang::SourceLocation, bool)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x43de959)

#25 0x000056211d650b1a clang::Sema::DiagnoseUseOfDecl(clang::NamedDecl*,
llvm::ArrayRef<clang::SourceLocation>, clang::ObjCInterfaceDecl const*, bool,
bool, clang::ObjCInterfaceDecl*)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x4111b1a)

#26 0x000056211d81166f CreateFunctionRefExpr(clang::Sema&,
clang::FunctionDecl*, clang::NamedDecl*, clang::Expr const*, bool,
clang::SourceLocation, clang::DeclarationNameLoc const&)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x42d266f)

#27 0x000056211d8437e7 clang::Sema::BuildCallToObjectOfClassType(clang::Scope*,
clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>,
clang::SourceLocation)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x43047e7)

#28 0x000056211d67c5bb clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*,
clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>,
clang::SourceLocation, clang::Expr*, bool)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x413d5bb)

#29 0x000056211d961434 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformCallExpr(clang::CallExpr*)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x4422434)

#30 0x000056211d95ba5b clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x441ca5b)

#31 0x000056211d95c82b clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformInitializer(clang::Expr*, bool)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x441d82b)

#32 0x000056211d95d8f7 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformReturnStmt(clang::ReturnStmt*)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x441e8f7)

#33 0x000056211d980ab0 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x4441ab0)

#34 0x000056211d9809ba clang::Sema::SubstStmt(clang::Stmt*,
clang::MultiLevelTemplateArgumentList const&)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x44419ba)

#35 0x000056211d99508c
clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation,
clang::FunctionDecl*, bool, bool, bool)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x445608c)

#36 0x000056211d67368c
clang::Sema::MarkFunctionReferenced(clang::SourceLocation,
clang::FunctionDecl*, bool)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x413468c)

#37 0x000056211d674080 clang::Sema::MarkDeclRefReferenced(clang::DeclRefExpr*,
clang::Expr const*)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x4135080)

#38 0x000056211d67428d 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-20190816/bin/clang-10+0x413528d)

#39 0x000056211d81dede
clang::Sema::FixOverloadedFunctionReference(clang::Expr*,
clang::DeclAccessPair, clang::FunctionDecl*)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x42deede)

#40 0x000056211d840229 FinishOverloadedCallExpr(clang::Sema&, clang::Scope*,
clang::Expr*, clang::UnresolvedLookupExpr*, clang::SourceLocation,
llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*,
clang::OverloadCandidateSet*, clang::OverloadCandidate**,
clang::OverloadingResult, bool)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x4301229)

#41 0x000056211d84061f clang::Sema::BuildOverloadedCallExpr(clang::Scope*,
clang::Expr*, clang::UnresolvedLookupExpr*, clang::SourceLocation,
llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool,
bool) (/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x430161f)

#42 0x000056211d67c1b8 clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*,
clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>,
clang::SourceLocation, clang::Expr*, bool)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x413d1b8)

#43 0x000056211d67d112 clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*,
clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>,
clang::SourceLocation, clang::Expr*)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x413e112)

#44 0x000056211d34c93f
clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*,
true>) (/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x3e0d93f)

#45 0x000056211d34760f clang::Parser::ParseCastExpression(bool, bool, bool&,
clang::Parser::TypeCastState, bool)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x3e0860f)

#46 0x000056211d349b04 clang::Parser::ParseCastExpression(bool, bool,
clang::Parser::TypeCastState, bool)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x3e0ab04)

#47 0x000056211d34acb1
clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x3e0bcb1)

#48 0x000056211d34b929
clang::Parser::ParseExpression(clang::Parser::TypeCastState)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x3e0c929)

#49 0x000056211d39675d
clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x3e5775d)

#50 0x000056211d3940d2
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*,
clang::Parser::ParsedAttributesWithRange&)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x3e550d2)

#51 0x000056211d395939
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x3e56939)

#52 0x000056211d390901 clang::Parser::ParseCompoundStatementBody(bool)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x3e51901)

#53 0x000056211d39b913 clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x3e5c913)

#54 0x000056211d306dd8
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x3dc7dd8)

#55 0x000056211d3295d0 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x3dea5d0)

#56 0x000056211d3021f9
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x3dc31f9)

#57 0x000056211d302ed1
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier) (.part.206)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x3dc3ed1)

#58 0x000056211d309c16
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x3dcac16)

#59 0x000056211d30a679
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x3dcb679)

#60 0x000056211d2fe339 clang::ParseAST(clang::Sema&, bool, bool)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x3dbf339)

#61 0x000056211cae9322 clang::CodeGenAction::ExecuteAction()
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x35aa322)

#62 0x000056211c451439 clang::FrontendAction::Execute()
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x2f12439)

#63 0x000056211c4148d5
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x2ed58d5)

#64 0x000056211c516ae3
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0x2fd7ae3)

#65 0x000056211a26ff80 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0xd30f80)

#66 0x000056211a1cc2ba main
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0xc8d2ba)

#67 0x00007faf63a30b97 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x21b97)

#68 0x000056211a26d61a _start
(/opt/compiler-explorer/clang-trunk-20190816/bin/clang-10+0xd2e61a)

clang-10: error: unable to execute command: Segmentation fault (core dumped)

clang-10: error: clang frontend command failed due to signal (use -v to see
invocation)


The compiler returned with status code 254.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>