https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118784
Bug ID: 118784 Summary: [modules] internal compiler error when consuming {fmt} within a C++20 module Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: thomas.khyn_gccbugzilla at m4x dot org Target Milestone: --- Hello, I have run into an internal compiler error when consuming {fmt} (https://github.com/fmtlib/fmg) within a C++20 module. My setup: - running on WSL (Ubuntu 24.04) - uname -r = 5.15.167.4-microsoft-standard-WSL2 - cmake 3.31.5 - gcc 15.0.1 20250205, build options `--prefix=/opt/gcc-dev --enable-languages=c,c++ --disable-multilib` - ninja 1.11.1 - directory with: - g...@github.com:fmtlib/fmt.git with master branch (although checking out earlier versions leads to the same result) checked out in an fmt subfolder - the following files CMakeLists.txt, main.cpp and fmt.cppm CMakeLists.txt: ```cmake cmake_minimum_required(VERSION 3.31) project(fmt_test) set(CMAKE_CXX_STANDARD 23) add_subdirectory(fmt) add_executable(main main.cpp) target_sources(main PRIVATE FILE_SET CXX_MODULES FILES fmt.cppm) target_link_libraries(main PRIVATE fmt::fmt) ``` main.cpp ```c++ import fmt; int main() { auto hw = fmt::format("{}, {}!", "Hello", "World"); return static_cast<int>(hw.size()); } ``` fmt.cppm ```c++ module; #include <fmt/format.h> export module fmt; export namespace fmt { using fmt::format; } ``` # Issue 1: FMT_MODULE set to OFF Steps to reproduce: ``` mkdir build && cd build cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Debug cmake --build . ``` Expected: The build completes (as it does in release mode or with Clang 21). Result: ``` [5/9] Building CXX object CMakeFiles/main.dir/fmt.cppm.o FAILED: CMakeFiles/main.dir/fmt.cppm.o CMakeFiles/main.dir/fmt.gcm /usr/bin/c++ -I/mnt/d/dev/sandbox/fmt_test/fmt/include -Wall -Wextra -g -std=gnu++23 -MD -MT CMakeFiles/main.dir/fmt.cppm.o -MF CMakeFiles/main.dir/fmt.cppm.o.d -fmodules-ts -fmodule-mapper=CMakeFiles/main.dir/fmt.cppm.o.modmap -MD -fdeps-format=p1689r5 -x c++ -o CMakeFiles/main.dir/fmt.cppm.o -c /mnt/d/dev/sandbox/fmt_test/fmt.cppm /mnt/d/dev/sandbox/fmt_test/fmt.cppm:9:8: internal compiler error: in core_vals, at cp/module.cc:6465 9 | export module fmt; | ^~~~~~ 0x29e60df internal_error(char const*, ...) ../../gcc/gcc/diagnostic-global-context.cc:517 0xb04991 fancy_abort(char const*, int, char const*) ../../gcc/gcc/diagnostic.cc:1722 0x86310a core_vals ../../gcc/gcc/cp/module.cc:6465 0x86310a tree_node_vals ../../gcc/gcc/cp/module.cc:7500 0xc8a0cd tree_value ../../gcc/gcc/cp/module.cc:9484 0xc8a0cd tree_node ../../gcc/gcc/cp/module.cc:9787 0xc8ce12 core_vals ../../gcc/gcc/cp/module.cc:6370 0xc8ce12 tree_node_vals ../../gcc/gcc/cp/module.cc:7500 0xc87fe2 decl_value ../../gcc/gcc/cp/module.cc:8121 0xc90bf1 depset::hash::find_dependencies(module_state*) ../../gcc/gcc/cp/module.cc:14443 0xc91a56 module_state::write_begin(elf_out*, cpp_reader*, module_state_config&, unsigned int&) ../../gcc/gcc/cp/module.cc:19323 0xc933c3 finish_module_processing(cpp_reader*) ../../gcc/gcc/cp/module.cc:21840 0xc132ea c_parse_final_cleanups() ../../gcc/gcc/cp/decl2.cc:5724 0xe944c0 c_common_parse_file() ../../gcc/gcc/c-family/c-opts.cc:1408 Please submit a full bug report, with preprocessed source (by using -freport-bug). Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. [6/9] Building CXX object fmt/CMakeFiles/fmt.dir/src/format.cc.o ninja: build stopped: subcommand failed. ``` Note: /usr/bin/c++ is mapped to development g++ on this WSL instance. I am attaching the pre-processed source after re-running the command that triggers the internal error with -freport-bug option: /usr/bin/c++ -I/mnt/d/dev/sandbox/fmt_test/fmt/include -Wall -Wextra -g -std=gnu++23 -MD -MT CMakeFiles/main.dir/fmt.cppm.o -MF CMakeFiles/main.dir/fmt.cppm.o.d -fmodules-ts -fmodule-mapper=CMakeFiles/main.dir/fmt.cppm.o.modmap -MD -fdeps-format=p1689r5 -x c++ -o CMakeFiles/main.dir/fmt.cppm.o -c /mnt/d/dev/sandbox/fmt_test/fmt.cppm -freport-bug