[Bug c/66370] New: compiler crashes when compiling a function with a huge number of arguments
jcarbaut at hotmail dot fr
gcc-bugzilla@gcc.gnu.org
Mon Jun 1 21:58:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66370
Bug ID: 66370
Summary: compiler crashes when compiling a function with a huge
number of arguments
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: jcarbaut at hotmail dot fr
Target Milestone: ---
This happens with the mingw-w64 distribution on Windows 7, with gcc-4.9.2, 64
bits.
I make a "fake" function with many arguments, with the following python script.
The function computes the sum of its arguments, which are all of type long. The
result is also of type long.
The variable "n" in the python script is the number of arguments. The output is
sent to a C file, which is then compiled.
n = 10907
for i in [n]:
print("long f(")
s = "return"
for j in range(1, 1 + i):
if j == i:
print(" long a%x) {" % j)
s += " a%x;" % j
print("%s\n}" % s)
else:
print(" long a%x," % j)
s += " a%x + \n" % j
With "gcc -c" (that is, no optimization), the compilation runs without a
problem for n<28040 and crashes for n=28040 or larger.
With "gcc -c -O1" or any higher level of optimization, the compilation runs for
n<10907 and crashes for n=10907 or larger.
While this function is utterly useless, it may show some bug in the compiler,
since, I guess, it's not supposed to crash on weird input. It's a kind, a very
trivial kind, of stress test for the compiler.
More information about the Gcc-bugs
mailing list