https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110052

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2023-05-31
     Ever confirmed|0                           |1

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
  /* This is the original code, the local variable is superfluous */
  int size = foo->size;
  if (!m)
    m = myrealloc(m, 256, &size);
  foo->size = size;

I'm not sure we are allowed to change the &size argument to &foo->size
since it's observable whether the argument is equal to &foo->size or
not since 'foo' is global and myrealloc could have access to it
and also clobber it.  Consider

myrealloc(..., int *size)
{
  *size = 4;
  foo->size = 0;
}

if 'foo' were global.  Can you make the testcase avoid these
considerations?  I think we have no pass doing this kind of transform.

Maybe sth along

  int size1, size2;
  foo (&size1);
  size2 = size1;
  bar (&size2);

of course since size1 escapes to foo() bar() might do the same as myrealloc
above and it would break passing &size1 to bar().

Reply via email to