[Bug analyzer/103658] New: 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:30:42 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103658
Bug ID: 103658
Summary: missing -Wanalyzer-use-of-uninitialized-value at -O1
and below for an array access
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: analyzer
Assignee: dmalcolm at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
I came across this while comparing the middle end -Wuninitialized with
-Wanalyzer-use-of-uninitialized-value. They both trigger at -O2. At -O1, only
-Wuninitialized triggers, even though the IL looks the same between the two
levels (as far as I can tell).
$ cat z.c && gcc -O1 -S -Wall -fdump-tree-uninit=/dev/stdout -fanalyzer z.c
int f (int i, int j)
{
int a[3];
a[0] = 1;
a[1] = 2;
if (i < 1) i = 1;
if (j < 1) j = 1;
return a[i + j];
}
;; Function f (f, funcdef_no=0, decl_uid=1979, cgraph_uid=1, symbol_order=0)
z.c: In function ‘f’:
z.c:9:11: warning: ‘a’ is used uninitialized [-Wuninitialized]
9 | return a[i + j];
| ~^~~~~~~
z.c:3:7: note: ‘a’ declared here
3 | int a[3];
| ^
int f (int i, int j)
{
int a[3];
int _1;
int _6;
int _8;
int _9;
<bb 2> [local count: 1073741824]:
_8 = MAX_EXPR <i_5(D), 1>;
_6 = MAX_EXPR <j_7(D), 1>;
_1 = _6 + _8;
_9 = a[_1];
a ={v} {CLOBBER};
return _9;
}
More information about the Gcc-bugs
mailing list