[Bug c/77767] New: Side-effect from VLA array parameters lost
jsm28 at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Sep 27 21:44:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77767
Bug ID: 77767
Summary: Side-effect from VLA array parameters lost
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: jsm28 at gcc dot gnu.org
Target Milestone: ---
The program
#include <stdio.h>
int
f (int a, int b[a++], int c, int d[c++])
{
printf ("%d %d\n", a, c);
}
int
main (void)
{
int dummy[10];
f (1, dummy, 1, dummy);
return 0;
}
outputs "1 2". It should output "2 2".
Side-effects from size expressions for array parameters are handled through the
pending_sizes member of struct c_arg_info. c_parser_parms_list_declarator may
call push_parm_decl any number of times, and push_parm_decl calls
grokdeclarator, and each grokdeclarator call overwrites the previous value of
expr storing expressions to evaluate on function entry, when what is required
is to update it instead.
Either push_parm_decl (or something further up the call chain) needs to deal
with merging with an existing value, or grokdeclarator could be made to do so
but then all callers wanting the existing overwriting would need to be updated
to pass a pointer to a variable with a NULL_TREE value, rather than an old
value that should be overwritten or an uninitialized variable.
More information about the Gcc-bugs
mailing list