[Bug middle-end/81962] -Wmaybe-uninitialized refers to wrong line (and only works with -O3) (Fortran)
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Apr 15 16:49:51 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81962
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also|https://gcc.gnu.org/bugzill |
|a/show_bug.cgi?id=63943 |
CC| |msebor at gcc dot gnu.org
Status|NEW |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #5 from Martin Sebor <msebor at gcc dot gnu.org> ---
This is, in fact, a duplicate of pr63943.
A C test case that reproduces the same effect is below. I doubt this will ever
be perfect.
$ cat a.c && gcc -O2 -S -Wall -fdump-tree-uninit-lineno=/dev/stdout a.c
int z;
void f (int i)
{
z = i + 1;
}
void g (int a, int b, int c)
{
int x;
if (a && b)
x = a + b;
if (b && c)
f (x + 1);
}
;; Function f (f, funcdef_no=0, decl_uid=1944, cgraph_uid=1, symbol_order=1)
void f (int i)
{
int _1;
<bb 2> [local count: 1073741824]:
[a.c:5:9] _1 = i_2(D) + 1;
[a.c:5:5] z = _1;
[a.c:6:1] return;
}
;; Function g (g, funcdef_no=1, decl_uid=1949, cgraph_uid=2, symbol_order=2)
...
a.c: In function ‘g’:
a.c:5:9: warning: ‘x’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
5 | z = i + 1;
| ~~^~~
a.c:10:7: note: ‘x’ was declared here
10 | int x;
| ^
void g (int a, int b, int c)
{
int x;
_Bool _1;
_Bool _2;
_Bool _3;
_Bool _4;
_Bool _5;
int _14;
<bb 2> [local count: 1073741824]:
[a.c:11:7] _1 = a_8(D) != 0;
[a.c:11:9] _2 = b_9(D) != 0;
[a.c:11:9] _3 = _1 & _2;
[a.c:11:6] if (_3 != 0)
goto <bb 3>; [50.00%]
else
goto <bb 7>; [50.00%]
<bb 7> [local count: 536870912]:
goto <bb 4>; [100.00%]
<bb 3> [local count: 536870913]:
[a.c:12:7] x_11 = a_8(D) + b_9(D);
<bb 4> [local count: 1073741824]:
# x_6 = PHI <x_10(D)(7), [a.c:12:7] x_11(3)>
[a.c:14:9] _4 = c_12(D) != 0;
[a.c:14:9] _5 = _2 & _4;
[a.c:14:6] if (_5 != 0)
goto <bb 5>; [50.00%]
else
goto <bb 8>; [50.00%]
<bb 8> [local count: 536870912]:
goto <bb 6>; [100.00%]
<bb 5> [local count: 536870913]:
[a.c:5:9] _14 = x_6 + 2;
[a.c:5:5] z = _14;
<bb 6> [local count: 1073741824]:
[a.c:16:1] return;
}
*** This bug has been marked as a duplicate of bug 63943 ***
More information about the Gcc-bugs
mailing list