https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114501
Bug ID: 114501 Summary: ICE during modref with LTO Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ipa Assignee: unassigned at gcc dot gnu.org Reporter: nerixdev at outlook dot de Target Milestone: --- Created attachment 57822 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57822&action=edit Preprocessed source The following C++ 20 code causes an ICE when compiled with -flto: #include <string_view> #include <array> inline constexpr auto make_it() { constexpr std::string_view view{"", 0}; std::array<char, 1> arr; arr[view.size()] = 'a'; // using 0 here won't cause an ICE return arr; } inline constexpr auto foo = make_it(); auto bar = foo; --- The same bug happens from GCC 10 to the current version listed as (trunc) on compiler-explorer: https://godbolt.org/z/xve6h5qhh. I'm using GCC 13.2.0 below. I've included the .ii file as the attachment. The code was compiled with g++ -std=c++20 foo.cpp -o foo.o -c -flto. Output of gcc -v -save-temps <all-your-options> <source-file>: Using built-in specs. COLLECT_GCC=gcc Target: x86_64-linux-gnu Configured with: /usr/src/gcc/configure --build=x86_64-linux-gnu --disable-multilib --enable-languages=c,c++,fortran,go Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 13.2.0 (GCC) COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++20' '-c' '-flto' '-freport-bug' '-mtune=generic' '-march=x86-64' /usr/local/libexec/gcc/x86_64-linux-gnu/13.2.0/cc1plus -E -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE foo.cpp -mtune=generic -march=x86-64 -std=c++20 -flto -freport-bug -fpch-preprocess -o foo.ii ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu" ignoring nonexistent directory "/usr/local/lib/gcc/x86_64-linux-gnu/13.2.0/include-fixed/x86_64-linux-gnu" ignoring nonexistent directory "/usr/local/lib/gcc/x86_64-linux-gnu/13.2.0/../../../../x86_64-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /usr/local/lib/gcc/x86_64-linux-gnu/13.2.0/../../../../include/c++/13.2.0 /usr/local/lib/gcc/x86_64-linux-gnu/13.2.0/../../../../include/c++/13.2.0/x86_64-linux-gnu /usr/local/lib/gcc/x86_64-linux-gnu/13.2.0/../../../../include/c++/13.2.0/backward /usr/local/lib/gcc/x86_64-linux-gnu/13.2.0/include /usr/local/include /usr/local/lib/gcc/x86_64-linux-gnu/13.2.0/include-fixed /usr/include/x86_64-linux-gnu /usr/include End of search list. COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++20' '-c' '-flto' '-freport-bug' '-mtune=generic' '-march=x86-64' /usr/local/libexec/gcc/x86_64-linux-gnu/13.2.0/cc1plus -fpreprocessed foo.ii -quiet -dumpbase foo.cpp -dumpbase-ext .cpp -mtune=generic -march=x86-64 -std=c++20 -version -flto -freport-bug -o foo.s GNU C++20 (GCC) version 13.2.0 (x86_64-linux-gnu) compiled by GNU C version 13.2.0, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.1, isl version isl-0.24-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 4919020133b793ebcf160ec1288a96cd during IPA pass: modref foo.cpp:13:15: internal compiler error: in streamer_write_chain, at tree-streamer-out.cc:543 13 | auto bar = foo; | ^ 0x1c989f6 internal_error(char const*, ...) ???:0 0x75eba6 fancy_abort(char const*, int, char const*) ???:0 0x106eece streamer_write_tree_body(output_block*, tree_node*) ???:0 0xd18d4d DFS::DFS(output_block*, tree_node*, bool, bool, bool) ???:0 0xd1a1f9 lto_output_tree(output_block*, tree_node*, bool, bool) ???:0 0xd1cc43 produce_asm_for_decls() ???:0 0xd9c852 ipa_write_summaries() ???:0 0xa67be7 symbol_table::finalize_compilation_unit() ???:0 Please submit a full bug report, with preprocessed source. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. The bug is not reproducible, so it is likely a hardware or OS problem.