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] Fix PR15791


On Thu, 27 Jan 2005, Andrew Pinski wrote:

>
> On Jan 27, 2005, at 9:57 AM, Richard Guenther wrote:
>
> > Hi!
> >
> > This patch adds the capability to fold comparisons of the form
> > &a[i] OP &a[j] (or plain a) as in PR15791.  It does not handle
> > &x.a[i] OP &x.a[j] currently, as these are presented in a
> > different lowered form to fold.
> >
> > Bootstrapped and tested on i686-pc-linux-gnu.  Ok?
> > (if yes, please apply)
> >
> > Richard.
>
> I don't think it handles the following C testcase (which should return
> true)
> as the size of the struct is zero (this is unlike C++):
>
> struct a{};
>
> int f()
> {
>    struct a b[2];
>    return &b[0] == &b[1];
> }

In fact, the generic dump for C looks like:

f ()
{
  int D.1120;
  struct a b[2];

  D.1120 = 1;
  return D.1120;
}

and the generic dump for C++:

int f() ()
{
  int D.1567;

  {
    struct a b[2];

    D.1567 = &b[0] == &b[1];
    return D.1567;
  }
}

so somehow it magically works (it just doesn't detect that in the
C++ case it is false).  Humm, it doesn't work for C++ at all it
seems - I guess there &b[1] is in another internal form again...

Richard.

--
Richard Guenther <richard dot guenther at uni-tuebingen dot de>
WWW: http://www.tat.physik.uni-tuebingen.de/~rguenth/


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