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

            Bug ID: 119102
           Summary: GCC 15.0 'import std;' fails with Ofast (not  with O3)
                    due to some openmp internal error
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: igor.machado at gmail dot com
  Target Milestone: ---

I successfully used GCC 15.0 to compile several code with CXX Modules, but I
noticed it fails with -Ofast, what does not happen with -O0, -O1, -O2 and -O3.
The error somehow mentions -fopenmp, which I don't use... code is trivial,
just:

file: main.cpp
```
import std;
int main() {  return 0; }
```

Compiled with FAILS:
g++-15 -std=c++23 -Ofast -fmodules -fsearch-include-path bits/std.cc main.cpp
-o example

```
In module imported at ./main.cpp:1:1:
std: error: module contains OpenMP, use ‘-fopenmp’ to enable
std: error: failed to read compiled module: Bad file data
std: note: compiled module file is ‘gcm.cache/std.gcm’
std: fatal error: returning to the gate for a mechanical issue
compilation terminated.
```

This works fine:
g++-15 -std=c++23 -O3 -fmodules -fsearch-include-path bits/std.cc main.cpp -o
example

Even when `-fopenmp` is enabled, compiler breaks:

```
$ g++-15 -std=c++23 -O3 -fopenmp -fmodules -freport-bug -fsearch-include-path
bits/std.cc main.cpp -o example]

/usr/include/c++/15/bits/std.cc:37:8: internal compiler error: in decl_node, at
cp/module.cc:8808
   37 | export module std;
      |        ^~~~~~
0x73d907e2a1c9 __libc_start_call_main
        ../sysdeps/nptl/libc_start_call_main.h:58
0x73d907e2a28a __libc_start_main_impl
        ../csu/libc-start.c:360
Please submit a full bug report, with preprocessed source.
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-15/README.Bugs> for instructions.
The bug is not reproducible, so it is likely a hardware or OS problem.
```

Version is: g++-15 (Ubuntu 15-20250213-1ubuntu1) 15.0.1 20250213 (experimental)
[master r15-7502-g26baa2c09b3]

Operating System is Ubuntu 24.04, with gcc-15 from Ubuntu 25.04 repo:
- deb http://cz.archive.ubuntu.com/ubuntu plucky main universe

I know that CXX Modules and "import std;" is still quite experimental, but it
seemed strange to generate a compiler bug, that's why I'm reporting.

Good luck!

Reply via email to