[Bug middle-end/96564] [11 Regression] New maybe use of uninitialized variable warning since r11-959
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Aug 11 17:10:10 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96564
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=87313
Keywords| |alias, diagnostic,
| |missed-optimization
--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
r11-959 enabled -Wuninitialized for allocated objects (alloca/VLA and malloc).
The underlying problem is the failure to take advantage of the non-aliasing
guarantee of the return value of these functions. One report that describes
this limitation is pr87313. A slightly simpler but even more obvious test case
is:
$ cat pr96564.c && gcc -O2 -S -Wall -Wextra -fdump-tree-optimized=/dev/stdout
pr96564.c
void f (int *x)
{
int a[*x];
if (a != x)
*a = 0;
*x = *a;
}
pr96564.c: In function ‘f’:
pr96564.c:8:6: warning: ‘*(<unknown>)[0]’ may be used uninitialized
[-Wmaybe-uninitialized]
8 | *x = *a;
| ~~~^~~~
;; Function f (f, funcdef_no=0, decl_uid=1931, cgraph_uid=1, symbol_order=0)
Removing basic block 5
f (int * x)
{
int[0:D.1936] * a.0;
sizetype _2;
int _8;
sizetype _9;
int prephitmp_18;
int pretmp_20;
<bb 2> [local count: 1073741824]:
_8 = *x_1(D);
_2 = (sizetype) _8;
_9 = _2 * 4;
a.0_11 = __builtin_alloca_with_align (_9, 32);
if (x_1(D) != a.0_11)
goto <bb 4>; [70.00%]
else
goto <bb 3>; [30.00%]
<bb 3> [local count: 322122544]:
pretmp_20 = (*a.0_11)[0];
<bb 4> [local count: 1073741824]:
# prephitmp_18 = PHI <pretmp_20(3), 0(2)>
*x_1(D) = prephitmp_18;
return;
}
More information about the Gcc-bugs
mailing list