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 middle-end/79234] warn on past the end reads by library functions


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=71501

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
See also bug 71501.

For another example consider the test case below.  Both functions attempt to
read a character array that isn't (necessarily) nul-terminated.  In f, the
function ends up reading the uninitialized contents of the local array and so
it should, arguably, be diagnosed by -Wuninitialized.  In g, the function reads
past the end of the local array so it could also be diagnosed by
-Wuninitialized, or 


$ cat z.c && gcc -O2 -S -Wall -Wextra -Wpedantic z.c
unsigned f (void)
{
  char d[4];
  __builtin_memcpy (d, "12", 2);
  return __builtin_strlen (d);   // missing warning
}

unsigned g (void)
{
  char d[4];
  __builtin_memcpy (d, "1234", 4);
  return __builtin_strlen (d);   // missing warning
}

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