This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] fix wrong gimple code with ptr to forward vla

On Mon, 25 Sep 2006, Olivier Hainque wrote:

>         * c-decl.c (grokdeclarator) [cdk_pointer]: If the pointed-to type
>         is anonymous and involves components of variable size, build an
>         artificial TYPE_DECL for it to force the size evaluation at the
>         pointer declaration point.

The pointer declaration point is in general in the middle of an 
expression.  This patch breaks

extern void abort (void);
extern void exit (int);

main (void)
  int a = 1;
  if (sizeof (*(++a, (char (*)[a])0)) != 2)
    abort ();
  exit (0);

where simply inserting a declaration before the containing expression 
won't work.

This patch might be safer if the TYPE_DECL were only inserted in the case 
of decl_context == NORMAL.  That should avoid the TYPENAME problems like 
the testcase I give (which should be added to the gcc.c-torture/execute 
testsuite) and also avoid possible problems with PARM (where in the case 
of declarations that aren't definitions, no special handling should be 
needed, and in the case of those that are definitions, gimplify_parameters 
should arrange the necessary evaluation of array sizes).

Joseph S. Myers

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]