[Bug analyzer/103658] missing -Wanalyzer-use-of-uninitialized-value at -O1 and below for an array access
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Dec 10 21:46:17 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103658
--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Actually, what I was really after is trying to see if the analyzer would print
the conditionals involved in the subscript expressions. But in the simple test
case in comment #0 there are no conditionals. They are here:
int f (int i, int j)
{
int a[3];
a[0] = 1;
a[1] = 2;
if (i < 1 || 3 < i) i = 1;
if (j < 1 || 5 < j) j = 1;
return a[i + j];
}
but it doesn't print them even at -O2 when it does warn:
z.c: In function ‘f’:
z.c:9:11: warning: use of uninitialized value ‘a[<unknown>]’ [CWE-457]
[-Wanalyzer-use-of-uninitialized-value]
9 | return a[i + j];
| ~^~~~~~~
‘f’: event 1
|
| 9 | return a[i + j];
| | ~^~~~~~~
| | |
| | (1) use of uninitialized value ‘a[<unknown>]’ here
|
More information about the Gcc-bugs
mailing list