This is the mail archive of the gcc-bugs@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]

[Bug c/84175] FAIL: c-c++-common/Warray-bounds-4.c -Wc++-compat strcpy (test for warnings, line 67)


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=83462
         Resolution|---                         |DUPLICATE

--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
The test failures are also discussed in bug 83462.  The root cause of the
missing warning is bug 83543: a missing strlen optimization.  The following
shows the problem:

$ cat z.c && gcc -O2 -S -Wall -Wextra -fdump-tree-wrestrict=/dev/stdout z.c
void f (int i)
{
  struct {
    char a[5], b[7];
  } x = { "", "012345" };   // strlen pass doesn't know how to compute the
lengths of x.a and x.b

  if (i < 1 || 2 < i)
    i = 1;

  __builtin_strcpy (x.a + i, x.b);

  __builtin_puts (x.a);
}



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

f (int i)
{
  struct 
  {
    char a[5];
    char b[7];
  } x;
  unsigned int i.0_1;
  unsigned int _2;
  char * _4;
  sizetype _13;
  sizetype prephitmp_14;

  <bb 2> [local count: 1073741825]:
  x = *.LC0;
  i.0_1 = (unsigned int) i_8(D);
  _2 = i.0_1 + 4294967295;
  if (_2 > 1)
    goto <bb 4>; [59.00%]
  else
    goto <bb 3>; [41.00%]

  <bb 3> [local count: 440234144]:
  _13 = (sizetype) i_8(D);

  <bb 4> [local count: 1073741824]:
  # prephitmp_14 = PHI <_13(3), 1(2)>
  _4 = &x.a + prephitmp_14;
  __builtin_strcpy (_4, &x.b);
  __builtin_puts (&x.a);
  x ={v} {CLOBBER};
  return;

}

*** This bug has been marked as a duplicate of bug 83462 ***

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