https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121175
Bug ID: 121175 Summary: [modules] ICE with explicit specialization of template class (internal compiler error: in tree_node, at cp/module.cc:9975) Product: gcc Version: 15.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: omerfaruko at gmail dot com Target Milestone: --- Created attachment 61916 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=61916&action=edit preprocessed source Confirmed with g++ (GCC) 15.1.1 20250425 and with build from https://gcc.gnu.org/pub/gcc/snapshots/15-20250712/ snapshot. reprod.ccm: ```cpp module; #include <format> export module reprod; export struct Reprod {}; template <> struct std::formatter<Reprod> { auto parse(std::format_parse_context &ctx) { return ctx.begin(); } template <typename FormatContext> auto format(Reprod value, FormatContext &ctx) const { return std::format_to(ctx.out(), "Reprod"); } }; ``` CMakeLists.txt: ```cmake cmake_minimum_required(VERSION 4.0) project(reprod) set(CMAKE_CXX_FLAGS "-fsanitize=undefined") set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) add_library(reprod) target_sources(reprod PRIVATE FILE_SET CXX_MODULES FILES reprod.ccm ) ``` mkdir build && cd build && cmake .. && ninja --verbose: ``` -- The C compiler identification is GNU 15.1.1 -- The CXX compiler identification is GNU 15.1.1 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /opt/gcc-15-20250712/bin/gcc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /opt/gcc-15-20250712/bin/g++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done (0.3s) -- Generating done (0.0s) -- Build files have been written to: /home/omer/src/reprod/build [1/4] /opt/gcc-15-20250712/bin/g++ -fsanitize=undefined -std=c++23 -E -x c++ /home/omer/src/reprod/reprod.ccm -MT CMakeFiles/reprod.dir/reprod.ccm.o.ddi -MD -MF CMakeFiles/reprod.dir/reprod.ccm.o.ddi.d -fmodules-ts -fdeps-file=CMakeFiles/reprod.dir/reprod.ccm.o.ddi -fdeps-target=CMakeFiles/reprod.dir/reprod.ccm.o -fdeps-format=p1689r5 -o CMakeFiles/reprod.dir/reprod.ccm.o.ddi.i [2/4] /usr/bin/cmake -E cmake_ninja_dyndep --tdi=CMakeFiles/reprod.dir/CXXDependInfo.json --lang=CXX --modmapfmt=gcc --dd=CMakeFiles/reprod.dir/CXX.dd @CMakeFiles/reprod.dir/CXX.dd.rsp [3/4] /opt/gcc-15-20250712/bin/g++ -fsanitize=undefined -std=c++23 -MD -MT CMakeFiles/reprod.dir/reprod.ccm.o -MF CMakeFiles/reprod.dir/reprod.ccm.o.d -fmodules-ts -fmodule-mapper=CMakeFiles/reprod.dir/reprod.ccm.o.modmap -MD -fdeps-format=p1689r5 -x c++ -o CMakeFiles/reprod.dir/reprod.ccm.o -c /home/omer/src/reprod/reprod.ccm FAILED: CMakeFiles/reprod.dir/reprod.ccm.o CMakeFiles/reprod.dir/reprod.gcm /opt/gcc-15-20250712/bin/g++ -fsanitize=undefined -std=c++23 -MD -MT CMakeFiles/reprod.dir/reprod.ccm.o -MF CMakeFiles/reprod.dir/reprod.ccm.o.d -fmodules-ts -fmodule-mapper=CMakeFiles/reprod.dir/reprod.ccm.o.modmap -MD -fdeps-format=p1689r5 -x c++ -o CMakeFiles/reprod.dir/reprod.ccm.o -c /home/omer/src/reprod/reprod.ccm /home/omer/src/reprod/reprod.ccm:5:8: internal compiler error: in tree_node, at cp/module.cc:9975 5 | export module reprod; | ^~~~~~ 0x22e8325 diagnostic_context::diagnostic_impl(rich_location*, diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag (*) [1], diagnostic_t) ???:0 0x22f85bf internal_error(char const*, ...) ???:0 0x7d1dc3 fancy_abort(char const*, int, char const*) ???:0 0x8ee353 depset::hash::find_dependencies(module_state*) ???:0 0x8ef121 module_state::write_begin(elf_out*, cpp_reader*, module_state_config&, unsigned int&) ???:0 0x8f07f3 finish_module_processing(cpp_reader*) ???:0 0x88c661 c_parse_final_cleanups() ???:0 0xa8a510 c_common_parse_file() ???:0 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. ninja: build stopped: subcommand failed. ``` Preprocessed source is attached: ``` /opt/gcc-15-20250712/bin/g++ -fsanitize=undefined -std=c++23 -MD -MT CMakeFiles/reprod.dir/reprod.ccm.o -MF CMakeFiles/reprod.dir/reprod.ccm.o.d -fmodules-ts -fmodule-mapper=CMakeFiles/reprod.dir/reprod.ccm.o.modmap -MD -fdeps-format=p1689r5 -x c++ -o CMakeFiles/reprod.dir/reprod.ccm.o -c /home/omer/src/reprod/reprod.ccm -freport-bug ```