https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105065
Bug ID: 105065 Summary: Internal compiler error (segfault) when calling a function with a sized array parameter returning a type bigger than 16 bytes Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: niget.tom at gmail dot com Target Milestone: --- The following code: -------------------------------------------------------- # 0 "main.c" # 0 "<built-in>" # 0 "<command-line>" # 1 "/usr/include/stdc-predef.h" 1 3 4 # 0 "<command-line>" 2 # 1 "main.c" typedef struct { char filler[17]; } big_struct; big_struct dummy(int size, char array[size]); int main() { dummy(0, 0); } -------------------------------------------------------- Gives the following error when built normally (`gcc main.c`): -------------------------------------------------------- during RTL pass: expand /tmp/gccbug/main.c: In function ‘main’: /tmp/gccbug/main.c:10:5: internal compiler error: Segmentation fault 10 | dummy(0, 0); // arguments don't matter | ^~~~~~~~~~~ 0xa563ed crash_signal ../../src/gcc/toplev.c:327 0x7f3d8de5651f ??? ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0 0x1134db4 get_size_range(range_query*, tree_node*, gimple*, tree_node**, int) ../../src/gcc/calls.c:1274 0x1134db4 get_size_range(range_query*, tree_node*, gimple*, tree_node**, int) ../../src/gcc/calls.c:1260 0x1129e96 get_size_range(tree_node*, tree_node**, int) ../../src/gcc/calls.c:1401 0x1129e96 maybe_warn_rdwr_sizes ../../src/gcc/calls.c:2034 0x1129e96 initialize_argument_information ../../src/gcc/calls.c:2626 0x1129e96 expand_call(tree_node*, rtx_def*, int) ../../src/gcc/calls.c:4010 0x105339e expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool) ../../src/gcc/expr.c:11287 0x10ad851 expand_expr_real(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool) ../../src/gcc/expr.c:8519 0x10ad851 expand_expr ../../src/gcc/expr.h:282 0x10ad851 expand_call_stmt ../../src/gcc/cfgexpand.c:2840 0x10ad851 expand_gimple_stmt_1 ../../src/gcc/cfgexpand.c:3871 0x10ad851 expand_gimple_stmt ../../src/gcc/cfgexpand.c:4035 0x1077e48 expand_gimple_basic_block ../../src/gcc/cfgexpand.c:6077 0x1077e48 execute ../../src/gcc/cfgexpand.c:6761 -------------------------------------------------------- `big_struct` can be pretty much anything as long as it's strictly bigger than 16 bytes. The types of `size` and `array` do not matter, as long as `array` is sized with `size`. The parameters given to `dummy` do not matter (I used 0 and 0 here, but a real size and array trigger the crash too). `dummy` must not have an implementation in the same compilation unit as its call site (it can be implemented in a separate file). Technical details: -------------------------------------------------------- Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/11/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='Ubuntu 11.2.0-7ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-11 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --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/gcc-11-ZPT0kp/gcc-11-11.2.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-11-ZPT0kp/gcc-11-11.2.0/debian/tmp-gcn/usr --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=2 Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 11.2.0 (Ubuntu 11.2.0-7ubuntu2) --------------------------------------------------------