<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/55634>55634</a>
        </td>
    </tr>

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

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          vagran
      </td>
    </tr>
</table>

<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 14.0.0
Target: x86_64-unknown-linux-gnu

clang version 13.0.0 (https://github.com/llvm/llvm-project.git c1baf946e6cf611ae871e34db5cfea0f94f4b5a0)
Target: x86_64-unknown-linux-gnu

Also tested on: clang version 12.0.0 (https://github.com/llvm/llvm-project/ b978a93635b584db380274d7c8963c73989944a1)

Clang downloaded from GitHub release page.

I also created repository with reproduction code: https://github.com/vagran/asio-awaitable-modules-problem-demo/tree/exp-lambdas

I have reported this bug [here](https://bugs.llvm.org/show_bug.cgi?id=51607) year ago, but no any reaction since that time. It is actually show-stopper for using C++20 modules with Clang.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJylVd-P2zYM_mucF8GGLf9-8MMlaboCAwZsA9a3Ay3LtnayZUjy5fLfj7Kd3KXXdW0XGIpEUeRHkfxUq-ZSHdRoRMM1sT0nrZJSncXYEaYa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