This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/70987] New: missing -Wuninitialized calling built-in string functions with an uninitialized argument
- 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: Fri, 06 May 2016 23:45:31 +0000
- Subject: [Bug middle-end/70987] New: missing -Wuninitialized calling built-in string functions with an uninitialized argument
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70987
Bug ID: 70987
Summary: missing -Wuninitialized calling built-in string
functions with an uninitialized argument
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
In the program below, all functions access elements of the uninitialized local
array, but only the first one causes a warning. The rest that make use of the
built-in functions do not. The same problem exists when calling the
corresponding library functions (with or without _FORTIFY_SOURCE defined).
The uninitialized warning should be issued even for built-ins and for the
corresponding library functions that GCC has knowledge of.
$ cat zzz.c && gcc -O2 -S -Wall -Wextra -Wpedantic zzz.c
void f0 (char*);
void f1 (void)
{
char a [4];
unsigned n = 0;
for (char *p = a; *p; ++n, ++p);
f0 (a + n);
}
void f2 (void)
{
char a [4];
unsigned n = __builtin_strlen (a);
f0 (a + n);
}
void f3 (void)
{
char a [4];
__builtin_strcat (a, "abc");
f0 (a);
}
void f4 (void)
{
char a [4];
char b [4];
__builtin_strcpy (a, b);
f0 (a);
}
zzz.c: In function âf1â:
zzz.c:8:21: warning: âaâ is used uninitialized in this function
[-Wuninitialize]
for (char *p = a; *p; ++n, ++p);
^~