https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114856
Bug ID: 114856
Summary: [14 regression][modules] ICE (segfault)
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: D.Klein at gsi dot de
Target Milestone: ---
Created attachment 58042
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58042&action=edit
/tmp/ccHpxCro.out - preprocessed source
❯ cat repro.cpp
module;
#include <array>
#include <string>
#include <vector>
export module repro;
export struct data {
std::vector<std::array<std::string, 3>> asdf{{"42","42","42"}};
};
❯ g++ -v -save-temps -freport-bug -fmodules-ts repro.cpp
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/home/dklein/gcc-master/libexec/gcc/x86_64-pc-linux-gnu/14.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ./configure --prefix=/home/dklein/gcc-master
--disable-multilib --disable-bootstrap : (reconfigured) ./configure
--prefix=/home/dklein/gcc-master --disable-multilib --disable-bootstrap :
(reconfigured) ./configure --prefix=/home/dklein/gcc-master --disable-multilib
--disable-bootstrap --enable-languages=c,c++,fortran,lto,objc --no-create
--no-recursion
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.0.1 20240425 (experimental) (GCC)
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-freport-bug' '-fmodules-ts'
'-shared-libgcc' '-mtune=generic' '-march=x86-64' '-dumpdir' 'a-'
/home/dklein/gcc-master/libexec/gcc/x86_64-pc-linux-gnu/14.0.1/cc1plus -E
-quiet -v -D_GNU_SOURCE repro.cpp -mtune=generic -march=x86-64 -freport-bug
-fmodules-ts -fpch-preprocess -o a-repro.ii
ignoring nonexistent directory
"/home/dklein/gcc-master/lib/gcc/x86_64-pc-linux-gnu/14.0.1/../../../../x86_64-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/home/dklein/gcc-master/lib/gcc/x86_64-pc-linux-gnu/14.0.1/../../../../include/c++/14.0.1
/home/dklein/gcc-master/lib/gcc/x86_64-pc-linux-gnu/14.0.1/../../../../include/c++/14.0.1/x86_64-pc-linux-gnu
/home/dklein/gcc-master/lib/gcc/x86_64-pc-linux-gnu/14.0.1/../../../../include/c++/14.0.1/backward
/home/dklein/gcc-master/lib/gcc/x86_64-pc-linux-gnu/14.0.1/include
/usr/local/include
/home/dklein/gcc-master/include
/home/dklein/gcc-master/lib/gcc/x86_64-pc-linux-gnu/14.0.1/include-fixed
/usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-freport-bug' '-fmodules-ts'
'-shared-libgcc' '-mtune=generic' '-march=x86-64' '-dumpdir' 'a-'
/home/dklein/gcc-master/libexec/gcc/x86_64-pc-linux-gnu/14.0.1/cc1plus
-fpreprocessed a-repro.ii -quiet -dumpdir a- -dumpbase repro.cpp -dumpbase-ext
.cpp -mtune=generic -march=x86-64 -version -freport-bug -fmodules-ts -o
a-repro.s
GNU C++17 (GCC) version 14.0.1 20240425 (experimental) (x86_64-pc-linux-gnu)
compiled by GNU C version 14.0.1 20240411 (Red Hat 14.0.1-0), GMP
version 6.2.1, MPFR version 4.2.1, MPC version 1.3.1, isl version none
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: 66103b0a3eb595c28eae89ea7eb332ba
repro.cpp:7:9: internal compiler error: Segmentation fault
7 | export module repro;
| ^~~~~~
0x12ff8df crash_signal
../.././gcc/toplev.cc:319
0xb512ae tree_check(tree_node*, char const*, int, char const*, tree_code)
../.././gcc/tree.h:3623
0xb512ae get_merge_kind
../.././gcc/cp/module.cc:10679
0xb512ae decl_value
../.././gcc/cp/module.cc:7787
0xb5a4a3 depset::hash::find_dependencies(module_state*)
../.././gcc/cp/module.cc:13592
0xb5b2f3 module_state::write_begin(elf_out*, cpp_reader*, module_state_config&,
unsigned int&)
../.././gcc/cp/module.cc:18198
0xb5c9a4 finish_module_processing(cpp_reader*)
../.././gcc/cp/module.cc:20562
0xae6ee1 c_parse_final_cleanups()
../.././gcc/cp/decl2.cc:5357
0xd37c50 c_common_parse_file()
../.././gcc/c-family/c-opts.cc:1329
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.
Preprocessed source stored into /tmp/ccHpxCro.out file, please attach this to
your bugreport.
repro.cpp compiles with GCC 13.2.0 (https://godbolt.org/z/Ph834fvja). A git
bisect from 1604f7cebc49220e47d584615bcd91b1fdc1267f to releases/gcc-13.2.0
suggests the following commit to introduce the regression:
commit 2823b4d96d9ec4ad4e67e5e8edaa1b060a467491
Author: Nathaniel Shead <[email protected]>
Date: Thu Feb 29 22:49:13 2024 +1100
c++: Ensure DECL_CONTEXT is set for temporary vars [PR114005]
Modules streaming requires DECL_CONTEXT to be set for anything streamed.
This patch ensures that 'create_temporary_var' does set a DECL_CONTEXT
for these variables (such as the backing storage for initializer_lists)
even if not inside a function declaration.
PR c++/114005
gcc/cp/ChangeLog:
* init.cc (create_temporary_var): Use current_scope instead of
current_function_decl.
gcc/testsuite/ChangeLog:
* g++.dg/modules/pr114005_a.C: New test.
* g++.dg/modules/pr114005_b.C: New test.
Signed-off-by: Nathaniel Shead <[email protected]>