https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97986
Bug ID: 97986
Summary: ICE in force_constant_size when applying va_arg to VLA
type
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: pascal_cuoq at hotmail dot com
Target Milestone: ---
This bug seems most similar to (but still different from)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59711 (in which a comment says
that it appears to have been fixed in GCC 6).
In GCC 10.2 and some earlier versions, compiling the following program
(Compiler Explorer link: https://gcc.godbolt.org/z/11ob5j ):
#include <stdarg.h>
int sum(int n, ...)
{
va_list ap;
va_start(ap, n);
int *input = va_arg(ap, int[n]);
int rc = 0;
for (int i = 0; i < n; i++)
rc += input[i];
return rc;
}
Produces the following error message:
In file included from <source>:1:
<source>: In function 'sum':
<source>:7:29: internal compiler error: in force_constant_size, at
gimplify.c:733
7 | int *input = va_arg(ap, int[n]);
| ^~~
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1