<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 - Varargs lambda causes crash"
   href="https://bugs.llvm.org/show_bug.cgi?id=32737">32737</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Varargs lambda causes crash
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>4.0
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>moconnor@directstream.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Attempting to compile:

    #include <string>
    #include <cstdarg>
    auto const static DISPLAY = [](char const *_fmt, ...) {
      std::string _format;
      _format.reserve(1024);
      _format.append(_fmt);
      _format.push_back('\n');

      va_list _args;
      va_start(_args, _fmt);
      std::vfprintf(stderr, _format.data(), _args);
      va_end(_args);
    };

with clang++ -std=c++11 -c produces:

0  clang-4.0       0x0000000001c44458
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 56
1  clang-4.0       0x0000000001c4241e llvm::sys::RunSignalHandlers() + 62
2  clang-4.0       0x0000000001c4256c
3  libpthread.so.0 0x00007fd153d5d390
4  clang-4.0       0x0000000002a30722
clang::Sema::SemaBuiltinVAStartImpl(clang::CallExpr*) + 1314
5  clang-4.0       0x0000000002a307d4
clang::Sema::SemaBuiltinVAStart(clang::CallExpr*) + 52
6  clang-4.0       0x0000000002a45b96
clang::Sema::CheckBuiltinFunctionCall(clang::FunctionDecl*, unsigned int,
clang::CallExpr*) + 3782
7  clang-4.0       0x0000000002bc21d5
clang::Sema::BuildResolvedCallExpr(clang::Expr*, clang::NamedDecl*,
clang::SourceLocation, llvm::ArrayRef<clang::Expr*>, clang::SourceLocation,
clang::Expr*, bool) + 1349
8  clang-4.0       0x0000000002bc2d0a clang::Sema::ActOnCallExpr(clang::Scope*,
clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>,
clang::SourceLocation, clang::Expr*, bool) + 570
9  clang-4.0       0x0000000002854572
clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*,
true>) + 3458
10 clang-4.0       0x000000000284ef2b clang::Parser::ParseCastExpression(bool,
bool, bool&, clang::Parser::TypeCastState) + 123
11 clang-4.0       0x000000000285141d clang::Parser::ParseCastExpression(bool,
bool, clang::Parser::TypeCastState) + 45
12 clang-4.0       0x00000000028514b9
clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) + 41
13 clang-4.0       0x0000000002851539
clang::Parser::ParseExpression(clang::Parser::TypeCastState) + 9
14 clang-4.0       0x0000000002895432 clang::Parser::ParseExprStatement() + 82
15 clang-4.0       0x000000000289288f
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::AllowedContsructsKind, clang::SourceLocation*,
clang::Parser::ParsedAttributesWithRange&) + 3455
16 clang-4.0       0x0000000002892ade
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::AllowedContsructsKind, clang::SourceLocation*) + 142
17 clang-4.0       0x0000000002897b09
clang::Parser::ParseCompoundStatementBody(bool) + 1785
18 clang-4.0       0x0000000002864e72
clang::Parser::ParseLambdaExpressionAfterIntroducer(clang::LambdaIntroducer&) +
1602
19 clang-4.0       0x0000000002866563 clang::Parser::ParseLambdaExpression() +
307
20 clang-4.0       0x000000000285036b clang::Parser::ParseCastExpression(bool,
bool, bool&, clang::Parser::TypeCastState) + 5307
21 clang-4.0       0x000000000285141d clang::Parser::ParseCastExpression(bool,
bool, clang::Parser::TypeCastState) + 45
22 clang-4.0       0x00000000028514b9
clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) + 41
23 clang-4.0       0x0000000002821070
clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) + 464
24 clang-4.0       0x0000000002830784
clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, unsigned int,
clang::SourceLocation*, clang::Parser::ForRangeInit*) + 1476
25 clang-4.0       0x000000000280c2ea
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier) + 314
26 clang-4.0       0x000000000280ca21
27 clang-4.0       0x000000000280ca5f
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier) + 31
28 clang-4.0       0x0000000002813cdf
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) + 287
29 clang-4.0       0x0000000002814597
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 199
30 clang-4.0       0x00000000028081fb clang::ParseAST(clang::Sema&, bool, bool)
+ 395
31 clang-4.0       0x00000000020f98ce clang::FrontendAction::Execute() + 286
32 clang-4.0       0x00000000020ca406
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 310
33 clang-4.0       0x000000000217e5e2
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 2930
34 clang-4.0       0x0000000000a39898 cc1_main(llvm::ArrayRef<char const*>,
char const*, void*) + 2424
35 clang-4.0       0x00000000009ba995 main + 6773
36 libc.so.6       0x00007fd152ce2830 __libc_start_main + 240
37 clang-4.0       0x0000000000a37859 _start + 41
Stack dump:
0.      Program arguments: /opt/compiler-explorer/clang-4.0.0/bin/clang-4.0
-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 -mdisable-fp-elim -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
/tmp/compiler-explorer-compiler117321-60-1scxlus.0nglhrrudi/output.gcno
-resource-dir /opt/compiler-explorer/clang-4.0.0/bin/../lib/clang/4.0.0
-c-isystem /usr/include/x86_64-linux-gnu -cxx-isystem
/usr/include/x86_64-linux-gnu -internal-isystem
/opt/compiler-explorer/gcc-6.3.0/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0
-internal-isystem
/opt/compiler-explorer/gcc-6.3.0/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/x86_64-linux-gnu
-internal-isystem
/opt/compiler-explorer/gcc-6.3.0/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/backward
-internal-isystem /usr/local/include -internal-isystem
/opt/compiler-explorer/clang-4.0.0/bin/../lib/clang/4.0.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-std=c++11 -fdeprecated-macro -fdebug-compilation-dir /compiler-explorer
-ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gcc -fcxx-exceptions
-fexceptions -fdiagnostics-show-option -mllvm --x86-asm-syntax=intel -o
/tmp/compiler-explorer-compiler117321-60-1scxlus.0nglhrrudi/output.s -x c++
<source> 
1.      <source>:10:3
<Spelling=/opt/compiler-explorer/clang-4.0.0/bin/../lib/clang/4.0.0/include/stdarg.h:33:57>:
current parser token ')'
2.      <source>:3:29: lambda expression parsing
3.      <source>:3:55: in compound statement ('{}')
clang-4.0: error: unable to execute command: Segmentation fault (core dumped)
clang-4.0: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 4.0.0 (tags/RELEASE_400/final 299826)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-4.0.0/bin
clang-4.0: note: diagnostic msg: PLEASE submit a bug report to
<a href="http://llvm.org/bugs/">http://llvm.org/bugs/</a> and include the crash backtrace, preprocessed source, and
associated run script.
clang-4.0: note: diagnostic msg: 
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-4.0: note: diagnostic msg: /tmp/example-cfd80e.cpp
clang-4.0: note: diagnostic msg: /tmp/example-cfd80e.sh
clang-4.0: note: diagnostic msg: 
********************
Compiler exited with result code 254

Running this on clang 3.8 produces:

$ clang++ -std=c++11 display.cpp -c
#0 0x000000000122fac5 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/clang-3.8+0x122fac5)
#1 0x000000000122d876 llvm::sys::RunSignalHandlers()
(/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/clang-3.8+0x122d876)
#2 0x000000000122daa1 SignalHandler(int)
(/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/clang-3.8+0x122daa1)
#3 0x00007f5911ff9370 __restore_rt (/lib64/libpthread.so.0+0xf370)
#4 0x0000000001de5eed clang::Sema::SemaBuiltinVAStartImpl(clang::CallExpr*)
(/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/clang-3.8+0x1de5eed)
#5 0x0000000001de7756 clang::Sema::SemaBuiltinVAStart(clang::CallExpr*)
(/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/clang-3.8+0x1de7756)
#6 0x0000000001de95a5
clang::Sema::CheckBuiltinFunctionCall(clang::FunctionDecl*, unsigned int,
clang::CallExpr*)
(/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/clang-3.8+0x1de95a5)
#7 0x0000000001f2959f clang::Sema::BuildResolvedCallExpr(clang::Expr*,
clang::NamedDecl*, clang::SourceLocation, llvm::ArrayRef<clang::Expr*>,
clang::SourceLocation, clang::Expr*, bool)
(/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/clang-3.8+0x1f2959f)
#8 0x0000000001f29fec clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*,
clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>,
clang::SourceLocation, clang::Expr*, bool)
(/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/clang-3.8+0x1f29fec)
#9 0x0000000001c14ff7
clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*,
true>)
(/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/clang-3.8+0x1c14ff7)
#10 0x0000000001c104a8 clang::Parser::ParseCastExpression(bool, bool, bool&,
clang::Parser::TypeCastState)
(/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/clang-3.8+0x1c104a8)
#11 0x0000000001c12a4d clang::Parser::ParseCastExpression(bool, bool,
clang::Parser::TypeCastState)
(/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/clang-3.8+0x1c12a4d)
#12 0x0000000001c12ad9
clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState)
(/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/clang-3.8+0x1c12ad9)
#13 0x0000000001c12b59
clang::Parser::ParseExpression(clang::Parser::TypeCastState)
(/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/clang-3.8+0x1c12b59)
#14 0x0000000001c44773 clang::Parser::ParseExprStatement()
(/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/clang-3.8+0x1c44773)
#15 0x0000000001c451ff
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::AllowedContsructsKind, clang::SourceLocation*,
clang::Parser::ParsedAttributesWithRange&)
(/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/clang-3.8+0x1c451ff)
#16 0x0000000001c45613
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::AllowedContsructsKind, clang::SourceLocation*)
(/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/clang-3.8+0x1c45613)
#17 0x0000000001c487f9 clang::Parser::ParseCompoundStatementBody(bool)
(/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/clang-3.8+0x1c487f9)
#18 0x0000000001c1ebda
clang::Parser::ParseLambdaExpressionAfterIntroducer(clang::LambdaIntroducer&)
(/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/clang-3.8+0x1c1ebda)
#19 0x0000000001c2070b clang::Parser::ParseLambdaExpression()
(/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/clang-3.8+0x1c2070b)
#20 0x0000000001c11329 clang::Parser::ParseCastExpression(bool, bool, bool&,
clang::Parser::TypeCastState)
(/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/clang-3.8+0x1c11329)
#21 0x0000000001c12a4d clang::Parser::ParseCastExpression(bool, bool,
clang::Parser::TypeCastState)
(/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/clang-3.8+0x1c12a4d)
#22 0x0000000001c12ad9
clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState)
(/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/clang-3.8+0x1c12ad9)
#23 0x0000000001beaa02
clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*)
(/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/clang-3.8+0x1beaa02)
#24 0x0000000001bfd046 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
unsigned int, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/clang-3.8+0x1bfd046)
#25 0x0000000001bd954f
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/clang-3.8+0x1bd954f)
#26 0x0000000001bd9b7e
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
(/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/clang-3.8+0x1bd9b7e)
#27 0x0000000001bdd4ff
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
(/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/clang-3.8+0x1bdd4ff)
#28 0x0000000001bddcd0
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
(/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/clang-3.8+0x1bddcd0)
#29 0x0000000001bd7183 clang::ParseAST(clang::Sema&, bool, bool)
(/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/clang-3.8+0x1bd7183)
#30 0x00000000018b0b4b clang::CodeGenAction::ExecuteAction()
(/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/clang-3.8+0x18b0b4b)
#31 0x0000000001610686 clang::FrontendAction::Execute()
(/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/clang-3.8+0x1610686)
#32 0x00000000015ed4ae
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/clang-3.8+0x15ed4ae)
#33 0x00000000016923da
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/clang-3.8+0x16923da)
#34 0x00000000008d1998 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*)
(/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/clang-3.8+0x8d1998)
#35 0x00000000008af32b main
(/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/clang-3.8+0x8af32b)
#36 0x00007f5911213b35 __libc_start_main (/lib64/libc.so.6+0x21b35)
#37 0x00000000008cdc04 _start
(/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/clang-3.8+0x8cdc04)
Stack dump:
0.      Program arguments:
/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/clang-3.8 -cc1
-triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-main-file-name display.cpp -mrelocation-model static -mthread-model posix
-mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases
-munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info
-debugger-tuning=gdb -coverage-file
/home/moconnor/Source/carte.git/llvm-carte/test_suite/C2-01-echo/display.cpp
-resource-dir
/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/../lib/clang/3.8.0
-internal-isystem
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5
-internal-isystem
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/x86_64-redhat-linux
-internal-isystem
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/backward
-internal-isystem /usr/local/include -internal-isystem
/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/../lib/clang/3.8.0/include
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-std=c++11 -fdeprecated-macro -fdebug-compilation-dir
/home/moconnor/Source/carte.git/llvm-carte/test_suite/C2-01-echo -ferror-limit
19 -fmessage-length 94 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions
-fdiagnostics-show-option -fcolor-diagnostics -o display.o -x c++ display.cpp 
1.      display.cpp:10:3
<Spelling=/home/moconnor/Applications/carte70/opt/srcci/carte70/bin/../lib/clang/3.8.0/include/stdarg.h:33:57>:
current parser token ')'
2.      display.cpp:3:29: lambda expression parsing
3.      display.cpp:3:55: in compound statement ('{}')
clang-3.8: error: unable to execute command: Segmentation fault (core dumped)
clang-3.8: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.8.0 
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/moconnor/Applications/carte70/opt/srcci/carte70/bin
clang-3.8: note: diagnostic msg: PLEASE submit a bug report to
<a href="http://llvm.org/bugs/">http://llvm.org/bugs/</a> and include the crash backtrace, preprocessed source, and
associated run script.
clang-3.8: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-3.8: note: diagnostic msg: /tmp/display-2c4f4f.cpp
clang-3.8: note: diagnostic msg: /tmp/display-2c4f4f.sh
clang-3.8: note: diagnostic msg: 

********************</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>