https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119076
Bug ID: 119076 Summary: ICE with Segmentation fault if using PCH Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: pch Assignee: unassigned at gcc dot gnu.org Reporter: trinxery at firemail dot cc Target Milestone: --- Shell to reproduce: ``` mkdir gccbug2 cd gccbug2 git clone --depth=1 'https://github.com/nlohmann/json' cd json mkdir build cd build cmake -DJSON_BuildTests=Off -DCMAKE_INSTALL_PREFIX=. .. make -j make install echo '#include "./include/nlohmann/json.hpp"\n#include <iostream>\nint main() { std::cout << nlohmann::json{}; }' > ./main.cxx g++-15 -O0 -fmodules-ts './include/nlohmann/json.hpp' -std=c++20 -I'./include/' g++-15 -v -save-temps -freport-bug -Winvalid-pch -O0 -fmodules-ts './main.cxx' -std=c++20 ``` (Is not reproducible without `-fmodules-ts`, or with g++-14 and g++-13, or without precompiling `json.hpp`) Output on machine with `gcc version 15.0.1 20250213 (experimental) [master r15-7502-g26baa2c09b3] (Debian 15-20250213-1)`: ``` COLLECT_GCC=g++-15 COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-linux-gnu/15/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 15-20250213-1' --with-bugurl=file:///usr/share/doc/gcc-15/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2,rust,cobol --prefix=/usr --with-gcc-major-version-only --program-suffix=-15 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/libexec --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-libstdcxx-backtrace --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/reproducible-path/gcc-15-15-20250213/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/reproducible-path/gcc-15-15-20250213/debian/tmp-gcn/usr --enable-offload-defaulted --without-cuda-driver --enable-checking=yes,extra,rtl --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 15.0.1 20250213 (experimental) [master r15-7502-g26baa2c09b3] (Debian 15-20250213-1) COLLECT_GCC_OPTIONS='-v' '-save-temps' '-freport-bug' '-Winvalid-pch' '-O0' '-fmodules' '-std=c++20' '-foffload-options=-l_GCC_m' '-shared-libgcc' '-mtune=generic' '-march=x86-64' '-dumpdir' 'a-' /usr/libexec/gcc/x86_64-linux-gnu/15/cc1plus -E -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE ./main.cxx -mtune=generic -march=x86-64 -std=c++20 -Winvalid-pch -freport-bug -fmodules -foffload-options=-l_GCC_m -O0 -fpch-preprocess -fasynchronous-unwind-tables -o a-main.ii ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/15" ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu" ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/15/include-fixed/x86_64-linux-gnu" ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/15/include-fixed" ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/15/../../../../x86_64-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /usr/include/c++/15 /usr/include/x86_64-linux-gnu/c++/15 /usr/include/c++/15/backward /usr/lib/gcc/x86_64-linux-gnu/15/include /usr/local/include /usr/include/x86_64-linux-gnu /usr/include End of search list. COLLECT_GCC_OPTIONS='-v' '-save-temps' '-freport-bug' '-Winvalid-pch' '-O0' '-fmodules' '-std=c++20' '-foffload-options=-l_GCC_m' '-shared-libgcc' '-mtune=generic' '-march=x86-64' '-dumpdir' 'a-' /usr/libexec/gcc/x86_64-linux-gnu/15/cc1plus -fpreprocessed a-main.ii -quiet -dumpdir a- -dumpbase main.cxx -dumpbase-ext .cxx -mtune=generic -march=x86-64 -O0 -Winvalid-pch -std=c++20 -version -freport-bug -fmodules -foffload-options=-l_GCC_m -fasynchronous-unwind-tables -o a-main.s GNU C++20 (Debian 15-20250213-1) version 15.0.1 20250213 (experimental) [master r15-7502-g26baa2c09b3] (x86_64-linux-gnu) compiled by GNU C version 15.0.1 20250213 (experimental) [master r15-7502-g26baa2c09b3], GMP version 6.3.0, MPFR version 4.2.1, MPC version 1.3.1, isl version isl-0.27-GMP GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 Compiler executable checksum: 93a4481bddb607656af83a1985fd9568 In file included from ./include/nlohmann/json.hpp:60, of module ././include/nlohmann/json.hpp, imported at ./main.cxx:1: ./include/nlohmann/detail/output/serializer.hpp: In instantiation of ‘static uint8_t nlohmann::json_abi_v3_11_3::detail::serializer<BasicJsonType>::decode(uint8_t&, uint32_t&, uint8_t) [with BasicJsonType = nlohmann::json_abi_v3_11_3::basic_json<>; uint8_t = unsigned char; uint32_t = unsigned int]’: ./include/nlohmann/detail/output/serializer.hpp:405:27: required from ‘void nlohmann::json_abi_v3_11_3::detail::serializer<BasicJsonType>::dump_escaped(const string_t&, bool) [with BasicJsonType = nlohmann::json_abi_v3_11_3::basic_json<>; string_t = std::__cxx11::basic_string<char>]’ 405 | switch (decode(state, codepoint, byte)) | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ ./include/nlohmann/detail/output/serializer.hpp:140:25: required from ‘void nlohmann::json_abi_v3_11_3::detail::serializer<BasicJsonType>::dump(const BasicJsonType&, bool, bool, unsigned int, unsigned int) [with BasicJsonType = nlohmann::json_abi_v3_11_3::basic_json<>]’ 140 | dump_escaped(i->first, ensure_ascii); | ^~~~~~~~~~~~ ./include/nlohmann/json.hpp:4014:15: required from ‘std::ostream& nlohmann::json_abi_v3_11_3::operator<<(std::ostream&, const basic_json<>&)’ 4014 | s.dump(j, pretty_print, false, static_cast<unsigned int>(indentation)); | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ./main.cxx:3:42: required from here 3 | int main() { std::cout << nlohmann::json{}; } | ^ ./include/nlohmann/detail/output/serializer.hpp:902:52: internal compiler error: Segmentation fault 902 | static const std::array<std::uint8_t, 400> utf8d = | ^~~~~ 0x7f38e924564f ??? ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0 0x7f38e922a3b7 __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 0x7f38e922a47a __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. ``` Output on another machine with `gcc version <same as above> (Ubuntu 15-20250213-1ubuntu1)`: ``` <...> ./include/nlohmann/detail/output/serializer.hpp:902:52: internal compiler error: Segmentation fault 902 | static const std::array<std::uint8_t, 400> utf8d = | ^~~~~ 0x30ec4d3 diagnostic_context::diagnostic_impl(rich_location*, diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag (*) [1], diagnostic_t) ???:0 0x3102033 internal_error(char const*, ...) ???:0 0x12cf8e3 store_init_value(tree_node*, tree_node*, vec<tree_node*, va_gc, vl_embed>**, int) ???:0 0x10c5edc cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int, cp_decomp*) ???:0 0x1218ffd instantiate_decl(tree_node*, bool, bool) ???:0 0x125224b instantiate_pending_templates(int) ???:0 0x10d9459 c_parse_final_cleanups() ???:0 0x134bae8 c_common_parse_file() ???:0 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. ```