[Bug tree-optimization/81437] missing -Wstringop-overflow reading past the end of a string

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Jan 22 10:25:00 GMT 2020


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2017-08-30 00:00:00         |2020-1-22
      Known to fail|9.0                         |10.0, 9.2.0

--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> ---
Calls to all built-in functions that expect a pointer into an object (not a
past-the-end pointer) should be diagnosed when passed an invalid pointer (such
as one past the end).  This bug is only about strings but ideally, pointers to
other types would be detected as well, although they should probably be
reported under a separate warning.  

Here are some other examples:

char a[4];

int f (void)
{
  return __builtin_strcmp (a, &a[4]);   // missing warning
}

int g (void)
{
  return __builtin_puts (&a[4]);   // missing warning
}

int h (int x, int y)
{
  int z;
  return __builtin_add_overflow (x, y, &z + 1) ? 0 : z;   // missing warning
}


More information about the Gcc-bugs mailing list