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

--- Comment #6 from Igor Machado Coelho <igor.machado at gmail dot com> ---
I just discovered, and came here to complement this issue, that I found a very
similar situation with -U_FORTIFY_SOURCE.

When I built without -U_FORTIFY_SOURCE, like:

g++-15 -std=c++23 -O3 -fmodules   -fsearch-include-path bits/std.cc main.cpp
uses_std.cppm -o exTest3

And then rebuild with -U_FORTIFY_SOURCE, it breaks:

g++-15 -U_FORTIFY_SOURCE -std=c++23 -O3 -fmodules  main.cpp uses_std.cppm -o
exTest3

```
main.cpp:3:24: internal compiler error: in import_export_decl, at
cp/decl2.cc:3526
    3 | int main() { return 0; }
      |                        ^
0x7661c5e2a1c9 __libc_start_call_main
        ../sysdeps/nptl/libc_start_call_main.h:58
0x7661c5e2a28a __libc_start_main_impl
        ../csu/libc-start.c:360
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-15/README.Bugs> for instructions.
uses_std.cppm:15:2: internal compiler error: in import_export_decl, at
cp/decl2.cc:3526
   15 | };
      |  ^
0x7d9a7602a1c9 __libc_start_call_main
        ../sysdeps/nptl/libc_start_call_main.h:58
0x7d9a7602a28a __libc_start_main_impl
        ../csu/libc-start.c:360
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-15/README.Bugs> for instructions.
```


However, if I build with -O0 without FORTIFY_SOURCE, then I'm able to add it on
rebuild it with -O1, -O2, -O3 and -Ofast.

If I build without FORTIFY_SOURCE and -O1 or -O2, it still breaks on rebuild
with FORTIFY_SOURCE (same as -O3).

It means that, for the moment, the only safe way I manage to build modules is
either including FORTIFY_SOURCE, and using -O0 to -O3 (-Ofast is broken), or
then if I don't use FORTIFY_SOURCE, then the only safe possibility is building
module with -O0. So, FORTIFY_SOURCE is a must now.

Reply via email to