[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


            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
    ([](){ 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_FLAGS="-std=c++20 -stdlib=libc++ -Wall -Werror -g -O0"
CXX_FLAGS="$CXX_FLAGS -fmodules -fimplicit-modules
$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
Target: x86_64-unknown-linux-gnu

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

Clang downloaded from GitHub release page.

I also created repository with reproduction code:

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