https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125963
Bug ID: 125963
Summary: ICE: File size limit exceeded when compiling array
with massive designated initializer index
Product: gcc
Version: 15.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: 1794833681 at qq dot com
Target Milestone: ---
Description:
Dear GCC Developers,
Hello! First of all, thank you for your incredible work in maintaining and
continuously improving GCC.
While testing some extreme edge cases with an automated fuzzing tool, I
encountered an interesting issue in GCC 15.2 that leads to an Internal Compiler
Error (ICE). When compiling a static array with an exceptionally large
designated initializer index (e.g., [0x80000000]), the compiler process is
terminated by a signal due to exceeding the system's file size limit.
>From the behavior, it seems that GCC attempts to generate and write out the
massive zero-initialized portion of the array to the output file, eventually
hitting the OS file size limit (SIGXFSZ).
I completely understand that this is an extreme corner case. However, I was
wondering if it might be possible to catch this earlier in the frontend?
Perhaps emitting a diagnostic error (like "size of array is too large") during
semantic analysis would be a safer graceful degradation than proceeding to code
generation and crashing.
I am not very familiar with GCC's internal limits for array sizes, so please
forgive me if this is expected behavior for such unusual inputs. I defer
entirely to your expert judgment.
Thank you very much for your time and guidance!
Steps to Reproduce:
Source Code (crash.c):
C
struct Point { int x, y; };
void trigger_bug(void) {
static struct Point pts[] = {
[0x80000000] = { .x = 10, .y = 20 },
[0x80000001] = { .x = 30, .y = 40 }
};
}
Compiler Version:
x86-64 gcc 15.2
Command Line:
Bash
gcc -c crash.c
(Note: This can be consistently reproduced on Compiler Explorer).
Actual Behavior:
The compiler terminates abruptly, reporting:
Plaintext
gcc: internal compiler error: File size limit exceeded signal terminated
program as
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
See <https://gcc.gnu.org/bugs/> for instructions.