https://gcc.gnu.org/bugzilla/show_bug.cgi?id=40635
--- Comment #16 from Martin Sebor <msebor at gcc dot gnu.org> ---
With the patch in comment #13 committed in
g:9695e1c23be5b5c55d572ced152897313ddb96ae GCC 12 prints the following for the
test case in comment #0:
pr40635.c: In function ‘server_init’:
pr40635.c:14:9: warning: ‘s42’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
14 | int s42, x;
| ^~~
But it doesn't show where the uninitialized variable is used. GCC 11 only
points to the variable's use but doesn't say which variable it is:
pr40635.c: In function ‘server_init’:
pr40635.c:39:8: warning: ‘s42’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
39 | if (sockt_rd < 0)
| ^
So things have gotten both better and worse.
The reason why the GCC 12 warning doesn't point to the use is because the use
statement (_28 = _16 < 0; in basic block 8 below) has no location:
<bb 8> [local count: 1073741824]:
# _16 = PHI <[pr40635.c:22:20] -1(12), s42_9(7), [pr40635.c:29:16] -1(14),
s42_18(D)(11), s42_9(13)>
[pr40635.c:38:5] foo ();
_28 = _16 < 0;
_5 = (int) _28;
_4 = -_5;
return _4;
The location can still be found in the mergephi3 dump
(pr40635.c.120t.mergephi3) and is gone from the phiopt2 dump
(pr40635.c.121t.phiopt2):
<bb 8> [local count: 5226752]:
<bb 9> [local count: 1073741824]:
# _16 = PHI <[../pr40635.c:22:20] -1(3), [../pr40635.c:30:12] s42_20(7),
[../pr40635.c:29:16] -1(8)>
[../pr40635.c:38:5] foo ();
[../pr40635.c:39:8] if (_16 < 0)
goto <bb 10>; [0.73%]
else
goto <bb 11>; [99.27%]
<bb 10> [local count: 7838309]:
<bb 11> [local count: 1073741824]:
# _1 = PHI <[../pr40635.c:40:16] -1(10), [../pr40635.c:41:12] 0(9)>
return _1;
}