<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 - Clang crashes on assertion "Instantiated local in inner and outer scopes" when invoking inner lambda"
   href="https://bugs.llvm.org/show_bug.cgi?id=36571">36571</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang crashes on assertion "Instantiated local in inner and outer scopes" when invoking inner 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>FreeBSD
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>release blocker
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>isoa@kapsi.fi
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=19982" name="attach_19982" title="Preprocessed source and associated run script">attachment 19982</a> <a href="attachment.cgi?id=19982&action=edit" title="Preprocessed source and associated run script">[details]</a></span>
Preprocessed source and associated run script

With Clang version 4 this code compiles and runs without any problems. Thus I
think this might be an issue to be fixed.

Using Clang 7.0.d20180119 on FreeBSD 11.1

Crash backtrace:

Assertion failed: (Current->LocalDecls.find(D) == Current->LocalDecls.end() &&
"Instantiated local in inner and outer scopes"), function InstantiatedLocal,
file
/wrkdirs/usr/ports/devel/llvm-devel/work/llvm-e89505778ede40acc3920d6ff13263404b37fef0/tools/clang/lib/Sema/SemaTemplateInstantiate.cpp,
line 2921.
#0 0x0000000001e9c4e8 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/llvm-devel/bin/clang-7.0+0x1e9c4e8)
#1 0x0000000001e9cb06 (/usr/local/llvm-devel/bin/clang-7.0+0x1e9cb06)
#2 0x0000000805041926 (/lib/libthr.so.3+0xe926)
#3 0x0000000805040ecf (/lib/libthr.so.3+0xdecf)
Stack dump:
0.      Program arguments: /usr/local/llvm-devel/bin/clang-7.0 -cc1 -triple
x86_64-portbld-freebsd11.1 -emit-obj -mrelax-all -disable-free -main-file-name
assertion.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim
-masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64
-dwarf-column-info -debugger-tuning=gdb -resource-dir
/usr/local/llvm-devel/lib/clang/7.0.0 -internal-isystem /usr/include/c++/v1
--std=c++17 -fdeprecated-macro -fdebug-compilation-dir
/home/dev/projects/c++/meta -ferror-limit 19 -fmessage-length 112
-fobjc-runtime=gnustep -fcxx-exceptions -fexceptions -fdiagnostics-show-option
-fcolor-diagnostics -o /tmp/assertion-53d8b8.o -x c++ assertion.cpp
1.      assertion.cpp:30:10: current parser token ')'
2.      assertion.cpp:27:16: parsing function body 'main'
3.      assertion.cpp:27:16: in compound statement ('{}')
4.      assertion.cpp:12:16: instantiating function definition
'chain::operator()(const (lambda at assertion.cpp:29:20), const (lambda at
assertion.cpp:29:50))::(anonymous class)::operator()<int>'
5.      assertion.cpp:13:22: instantiating function definition
'chain::operator()(const (lambda at assertion.cpp:29:20), const (lambda at
assertion.cpp:29:50))::(anonymous class)::operator()(int &)::(anonymous
class)::operator()<(lambda at assertion.cpp:13:22), (lambda at
assertion.cpp:29:20), (lambda at assertion.cpp:29:50)>'
6.      assertion.cpp:13:22: instantiating function definition
'chain::operator()(const (lambda at assertion.cpp:29:20), const (lambda at
assertion.cpp:29:50))::(anonymous class)::operator()(int &)::(anonymous
class)::operator()<(lambda at assertion.cpp:13:22), (lambda at
assertion.cpp:29:50)>'
clang-7.0: error: unable to execute command: Abort trap (core dumped)
clang-7.0: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 7.0.0
Target: x86_64-portbld-freebsd11.1
Thread model: posix
InstalledDir: /usr/local/llvm-devel/bin
clang-7.0: note: diagnostic msg: PLEASE submit a bug report to
<a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a> and include the crash backtrace, preprocessed source,
and associated run script.
clang-7.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-7.0: note: diagnostic msg: /tmp/assertion-530b62.cpp
clang-7.0: note: diagnostic msg: /tmp/assertion-530b62.sh
clang-7.0: 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>