https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123627

            Bug ID: 123627
           Summary: ICE using local lambda in module partition
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: cjangus at gmail dot com
  Target Milestone: ---

Created attachment 63358
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=63358&action=edit
Preprocessed sources for two module units

The following module partition compiles successfully but causes a segmentation
fault at the point of being imported into the primary module interface. It
seems to be specific to the local lambda.

```
module;
#include <ranges>

export module repro:part;

auto const lam1 = [](auto const& x) {
  return x;
  };

auto fn() -> void
{
  auto const lam2 = [](auto const& x) {
    return x;
    };

  int ar[] = { 0 };

  for (auto x : ar | std::views::transform(lam1)) // ok
  { (void)x; }
  for (auto y : ar | std::views::transform(lam2)) // dies
  { (void)y; }
}
```

Target: x86_64-pc-linux-gnu
Configured with: ../configure --prefix=/opt/gcc-latest --enable-languages=c,c++
--enable-libstdcxx-debug --disable-bootstrap --disable-multilib
--disable-libvtv --disable-libssp --disable-libffi --with-system-zlib
--without-isl --with-arch_64=x86-64-v2
--with-bugurl=https://gcc.gnu.org/bugzilla
gcc version 16.0.0 20260111 (experimental) (GCC)

Compilation command lines:
g++ -std=c++2b -c -fmodules repro-part.cppm
g++ -std=c++2b -c -fmodules repro.cppm

Output:
repro.cppm:1:8: internal compiler error: Segmentation fault
    1 | export module repro;
      |        ^~~~~~

Reply via email to