[Bug middle-end/79234] warn on past the end reads by library functions
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Mar 29 19:16:00 GMT 2017
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
}
More information about the Gcc-bugs
mailing list