Reduced testcase from gcc.dg/builtin-object-size-1.c:

void abort(void);
int main (void)
{
  void *b = L"abcd";
  if (__builtin_object_size (b + 2, 0) != sizeof (L"abcd") - 2)
    abort ();
  return 0;
}

now, CCP propagates the "constant" &L"abcd"[0] to the addition stmt:

  b_1 = &"a"[0];
  D.1526_2 = &"a"[0] + 2B;

which does not simplify (it can't, array element size is four).  Now,
the objsz pass does not deal with this (non-gimple?) form and punts:

Computing maximum object size for D.1526_2:
D.1526_2: maximum object size 4294967293
test ()
{
  unsigned int D.1527;
  void * D.1526;

<bb 2>:
  D.1526_2 = &"a"[0] + 2B;
  D.1527_3 = 0fffffffd;
  if (D.1527_3 != 14) goto <L0>; else goto <L1>;

<L0>:;
  abort ();

<L1>:;
  return;

}

With fixing PR27529, this triggers for all the regular builtin-object-size-?.c
tests.


-- 
           Summary: CCP produces non-gimple statements
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: critical
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rguenth at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27532

Reply via email to