https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119154
Bug ID: 119154 Summary: GCC 15.0 std module with <string> compiled with -O3 breaks when loaded with -O0 (not -O1, -O2 and -Ofast) 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 stumbled on another strange gcc 15 bug when doing some basic CXX module testing (just recently reported some -Ofast with -fopenmp bug, but this is different now). When I build the std module with <string> and -O3, it works: main.cpp ``` #include <string> import std; int main(){return 0;} ``` Just build with: g++-15 -std=c++23 -O3 -fmodules -fsearch-include-path bits/std.cc main.cpp Then, gcm.cache/std.gcm is created. Finally, I can rebuild without the 'std' module and reuse from cache, and it works fine with -O3: g++-15 -std=c++23 -O3 -fmodules main.cpp Strangely, when I rebuild with -O0, it breaks: ``` $ g++-15 -std=c++23 -O0 -fmodules main.cpp -freport-bug main.cpp:3:24: internal compiler error: in import_export_decl, at cp/decl2.cc:3526 3 | int main() { return 0; } | ^ 0x718bb9c2a1c9 __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 0x718bb9c2a28a __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. ``` If I rebuild with -O1, -O2, -O3 or even -Ofast, it runs fine... only -O0 is problematic. Strangely, the header <string> is not even being used... but if I remove it, then the bug is gone. My system is Ubuntu 24.04 with gcc-15: $ g++-15 --version g++-15 (Ubuntu 15-20250213-1ubuntu1) 15.0.1 20250213 (experimental) [master r15-7502-g26baa2c09b3] Sorry for the inconvenience, and good luck!