This is the mail archive of the gcc-patches@gcc.gnu.org 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 to clean up uses of default_function_array_conversion


On Wed, 15 Jun 2005, Richard Guenther wrote:

> > A new version will need to be posted as it changes part of build_unary_op
> > I touched.  I expect this new version will get rid of one of the remaining
> > outside-parser calls to default_function_array_conversion, which would be
> > good.
> 
> Indeed.  Updated patch and re-bootstrapped and regtested on
> i686-pc-linux-gnu (C language only).
> 
> Ok for mainline?

This patch changes from having

  TREE_SIDE_EFFECTS (adr) = 0;   /* Default would be, same as EXP.  */

only for addresses of variables to having it for all array-to-pointer 
conversions.  This is not safe, since the address of an array can have 
side effects.  For example, the following test (which should go in 
gcc.c-torture/execute) passes before your patch but fails with it applied.

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

typedef __SIZE_TYPE__ size_t;

size_t a;
int b;
char c[2][2];

int
main (void)
{
  a = ((size_t)-1)|(size_t)c[++b];
  if (b != 1)
    abort ();
  exit (0);
}

-- 
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/
    jsm@polyomino.org.uk (personal mail)
    joseph@codesourcery.com (CodeSourcery mail)
    jsm28@gcc.gnu.org (Bugzilla assignments and CCs)


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