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); ^~