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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2016-10-07 00:00:00         |2020-2-19
          Component|middle-end                  |tree-optimization
      Known to fail|                            |10.0, 7.3.0, 8.2.0, 9.1.0

--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> ---
A simpler test case (that doesn't involve __builtin_object_size checking):

$ cat z.c && gcc -O2 -S -Wall -Wextra -fdump-tree-optimized=/dev/stdout z.c
const char a[] = "0123456789";

void f (int i)
{
  if (__builtin_strlen (a + i) > 30)   // folded
    __builtin_abort ();
}

void g (int i)
{
  const char *p = a + i;
  if (__builtin_strlen (p) > 30)   // not folded
    __builtin_abort ();
}


;; Function f (f, funcdef_no=0, decl_uid=1931, cgraph_uid=1, symbol_order=1)

f (int i)
{
  <bb 2> [local count: 1073741824]:
  return;

}



;; Function g (g, funcdef_no=1, decl_uid=1934, cgraph_uid=2, symbol_order=2)

g (int i)
{
  const char * p;
  sizetype _1;
  long unsigned int _2;

  <bb 2> [local count: 1073741824]:
  _1 = (sizetype) i_3(D);
  p_4 = &a + _1;
  _2 = __builtin_strlen (p_4);
  if (_2 > 30)
    goto <bb 3>; [0.00%]
  else
    goto <bb 4>; [100.00%]

  <bb 3> [count: 0]:
  __builtin_abort ();

  <bb 4> [local count: 1073741824]:
  return;

}

Reply via email to