<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 - Broken lambdas with C++ modules"
   href="https://bugs.llvm.org/show_bug.cgi?id=51607">51607</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Broken lambdas with C++ modules
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>release blocker
          </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>artyom.lebedev@gmail.com
          </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>Consider the following code:

export module main;// <<< Remove this line to make it work correctly

import <iostream>;

export int
main()
{
    ([](){ std::cout << "callback 1\n"; })();
    ([](){ std::cout << "callback 2\n"; })();
    return 0;
}

It has the following output:
callback 1
callback 1

Expected output (it is correct, when the code compiled without modules):
callback 1
callback 2

I use the following commands for compiling:
CXX="/opt/clang-12/bin/clang++"
CXX_FLAGS="-std=c++20 -stdlib=libc++ -Wall -Werror -g -O0"
CXX_FLAGS="$CXX_FLAGS -fmodules -fimplicit-modules
-fmodules-cache-path=modules-cache"
$CXX -c $CXX_FLAGS test.cpp -o test.o
$CXX $CXX_FLAGS test.o -o test_mod

clang version 13.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
c1baf946e6cf611ae871e34db5cfea0f94f4b5a0)
Target: x86_64-unknown-linux-gnu

Also tested on: clang version 12.0.0 (<a href="https://github.com/llvm/llvm-project/">https://github.com/llvm/llvm-project/</a>
b978a93635b584db380274d7c8963c73989944a1)

Clang downloaded from GitHub release page.

I also created repository with reproduction code:
<a href="https://github.com/vagran/asio-awaitable-modules-problem-demo/tree/exp-lambdas">https://github.com/vagran/asio-awaitable-modules-problem-demo/tree/exp-lambdas</a></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>