This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/79234] warn on past the end reads by library functions
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 29 Mar 2017 19:16:45 +0000
- Subject: [Bug middle-end/79234] warn on past the end reads by library functions
- Auto-submitted: auto-generated
- References: <bug-79234-4@http.gcc.gnu.org/bugzilla/>
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
}