https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125673

            Bug ID: 125673
           Summary: ice at calls.cc:3766 on code trying to pass gigantic
                    struct via stack
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lu.maltsis at postgrad dot manchester.ac.uk
  Target Milestone: ---

```sh
$ gcc /tmp/bug.c
/tmp/bug.c: In function ‘main’:
/tmp/bug.c:10:3: sorry, unimplemented: passing too large argument on stack
   10 |   f (x);
      |   ^~~~~
during RTL pass: expand
/tmp/bug.c:10:3: internal compiler error: in expand_call, at calls.cc:3766
0x25b273b internal_error(char const*, ...)
        /home/user/software/gcc/slot-a/src/gcc/diagnostic-global-context.cc:787
0x9d0b6f fancy_abort(char const*, int, char const*)
        /home/user/software/gcc/slot-a/src/gcc/diagnostics/context.cc:1813
0x7b0497 expand_call(tree_node*, rtx_def*, int)
        /home/user/software/gcc/slot-a/src/gcc/calls.cc:3766
0xce8216 expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
        /home/user/software/gcc/slot-a/src/gcc/expr.cc:12677
0xbab078 expand_expr(tree_node*, rtx_def*, machine_mode, expand_modifier)
        /home/user/software/gcc/slot-a/src/gcc/expr.h:323
0xbab078 expand_call_stmt
        /home/user/software/gcc/slot-a/src/gcc/cfgexpand.cc:3205
0xbab078 expand_gimple_stmt_1
        /home/user/software/gcc/slot-a/src/gcc/cfgexpand.cc:4243
0xbab078 expand_gimple_stmt
        /home/user/software/gcc/slot-a/src/gcc/cfgexpand.cc:4390
0xbb1c4f expand_gimple_basic_block
        /home/user/software/gcc/slot-a/src/gcc/cfgexpand.cc:6507
0xbb382f execute
        /home/user/software/gcc/slot-a/src/gcc/cfgexpand.cc:7254
/home/user/software/gcc/slot-a/libexec/gcc/x86_64-pc-linux-gnu/17.0.0/cc1
-quiet -imultiarch x86_64-linux-gnu /tmp/bug.c -quiet -dumpdir a- -dumpbase
bug.c -dumpbase-ext .c -mtune=generic -march=x86-64 -o /tmp/ccfl7Z6d.s
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.
```

```sh
$ cat /tmp/bug.c
typedef struct {
  char a[4294967169];
} big;

void f (big x);

int main (void)
{
  big x = {""};
  f (x);
}
```
This seems to happen for all values 4294967169 (which is UINT_MAX - 128) and
above. I could not reproduce the bug without the "sorry" error.

https://godbolt.org/z/1PWcz8rdY
Triggers on b5a3b87
(https://github.com/gcc-mirror/gcc/commit/b5a3b874b8df2ea2ca82bd97fcd5906f7ebe82d8)

Preprocessed source:
```sh
$ cat /tmp/ccsB2fVn.out
// Target: x86_64-pc-linux-gnu
// Configured with: /home/user/software/gcc/slot-a/src/configure
--prefix=/home/user/software/gcc/slot-a --enable-languages=c,c++
--disable-bootstrap --disable-multilib --with-gmp=/usr --with-mpfr=/usr
--with-mpc=/usr
// Thread model: posix
// Supported LTO compression algorithms: zlib zstd
// gcc version 17.0.0 20260604 (experimental) (GCC)
//
// /tmp/bug.c: In function ‘main’:
// /tmp/bug.c:10:3: sorry, unimplemented: passing too large argument on stack
//    10 |   f (x);
//       |   ^~~~~
// during RTL pass: expand
// /tmp/bug.c:10:3: internal compiler error: in expand_call, at calls.cc:3766
// 0x25b273b internal_error(char const*, ...)
//      /home/user/software/gcc/slot-a/src/gcc/diagnostic-global-context.cc:787
// 0x9d0b6f fancy_abort(char const*, int, char const*)
//      /home/user/software/gcc/slot-a/src/gcc/diagnostics/context.cc:1813
// 0x7b0497 expand_call(tree_node*, rtx_def*, int)
//      /home/user/software/gcc/slot-a/src/gcc/calls.cc:3766
// 0xce8216 expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
//      /home/user/software/gcc/slot-a/src/gcc/expr.cc:12677
// 0xbab078 expand_expr(tree_node*, rtx_def*, machine_mode, expand_modifier)
//      /home/user/software/gcc/slot-a/src/gcc/expr.h:323
// 0xbab078 expand_call_stmt
//      /home/user/software/gcc/slot-a/src/gcc/cfgexpand.cc:3205
// 0xbab078 expand_gimple_stmt_1
//      /home/user/software/gcc/slot-a/src/gcc/cfgexpand.cc:4243
// 0xbab078 expand_gimple_stmt
//      /home/user/software/gcc/slot-a/src/gcc/cfgexpand.cc:4390
// 0xbb1c4f expand_gimple_basic_block
//      /home/user/software/gcc/slot-a/src/gcc/cfgexpand.cc:6507
// 0xbb382f execute
//      /home/user/software/gcc/slot-a/src/gcc/cfgexpand.cc:7254
// -quiet -imultiarch x86_64-linux-gnu /tmp/bug.c -quiet -dumpdir a- -dumpbase
bug.c -dumpbase-ext .c -mtune=generic -march=x86-64 -freport-bug -o -
-frandom-seed=0 -fdump-noaddr
// 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.

// /home/user/software/gcc/slot-a/libexec/gcc/x86_64-pc-linux-gnu/17.0.0/cc1
-quiet -imultiarch x86_64-linux-gnu /tmp/bug.c -quiet -dumpdir a- -dumpbase
bug.c -dumpbase-ext .c -mtune=generic -march=x86-64 -freport-bug -o -
-frandom-seed=0 -fdump-noaddr

# 0 "/tmp/bug.c"
# 0 "<built-in>"
# 0 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3
# 0 "<command-line>" 2
# 1 "/tmp/bug.c"
typedef struct {
  char a[4294967169];
} big;

void f (big x);

int main (void)
{
  big x = {""};
  f (x);
}
```
  • [Bug c/125673] Ne... lu.maltsis at postgrad dot manchester.ac.uk via Gcc-bugs

Reply via email to