[llvm-bugs] [Bug 51607] New: Broken lambdas with C++ modules

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Aug 24 13:10:22 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=51607

            Bug ID: 51607
           Summary: Broken lambdas with C++ modules
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: release blocker
          Priority: P
         Component: C++2a
          Assignee: unassignedclangbugs at nondot.org
          Reporter: artyom.lebedev at gmail.com
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

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 (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

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210824/343d736e/attachment.html>


More information about the llvm-bugs mailing list