public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug tree-optimization/101770] New: -Wmaybe-uninitialized false alarm with only locals in GNU diffutils @ 2021-08-03 23:50 eggert at cs dot ucla.edu 2021-08-04 6:34 ` [Bug tree-optimization/101770] " rguenth at gcc dot gnu.org ` (5 more replies) 0 siblings, 6 replies; 7+ messages in thread From: eggert at cs dot ucla.edu @ 2021-08-03 23:50 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101770 Bug ID: 101770 Summary: -Wmaybe-uninitialized false alarm with only locals in GNU diffutils Product: gcc Version: 11.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: eggert at cs dot ucla.edu Target Milestone: --- Created attachment 51256 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51256&action=edit False alarm with gcc -O2 -Wmaybe-uninitialized and only locals I found this problem while compiling sdiff.c from GNU diffutils. The attached is is a simplified version. It appears to be distinct from GCC bug 101768 since it involves only local variables. Compile it this way: gcc -O2 -Wmaybe-uninitialized -S w.i The output is: w.i: In function ‘edit’: w.i:50:18: warning: ‘cmd1’ may be used uninitialized in this function [-Wmaybe-uninitialized] 50 | return !cmd1; | ^~~~~ This is a false alarm, because line 50 can be reached only if cmd0=='e', and if cmd0=='e' then the previous switch statement (inside the while loop - line 27) guarantees that cmd1 has been initialized. I briefly tried to simplify the example further, but failed. For example, if I remove line 16 ("case '2':") the false alarm goes away. This is with gcc (GCC) 11.2.1 20210728 (Red Hat 11.2.1-1) on x86-64. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/101770] -Wmaybe-uninitialized false alarm with only locals in GNU diffutils 2021-08-03 23:50 [Bug tree-optimization/101770] New: -Wmaybe-uninitialized false alarm with only locals in GNU diffutils eggert at cs dot ucla.edu @ 2021-08-04 6:34 ` rguenth at gcc dot gnu.org 2021-08-05 14:59 ` msebor at gcc dot gnu.org ` (4 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: rguenth at gcc dot gnu.org @ 2021-08-04 6:34 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101770 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2021-08-04 Blocks| |24639 Ever confirmed|0 |1 Status|UNCONFIRMED |NEW --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- GCC is unable to prove that the conditions guarding the use match those of the initialization. The loop around the switch likely contributes to that. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24639 [Bug 24639] [meta-bug] bug to track all Wuninitialized issues ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/101770] -Wmaybe-uninitialized false alarm with only locals in GNU diffutils 2021-08-03 23:50 [Bug tree-optimization/101770] New: -Wmaybe-uninitialized false alarm with only locals in GNU diffutils eggert at cs dot ucla.edu 2021-08-04 6:34 ` [Bug tree-optimization/101770] " rguenth at gcc dot gnu.org @ 2021-08-05 14:59 ` msebor at gcc dot gnu.org 2022-11-20 5:00 ` law at gcc dot gnu.org ` (3 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: msebor at gcc dot gnu.org @ 2021-08-05 14:59 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101770 Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |diagnostic CC| |msebor at gcc dot gnu.org --- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> --- Here's output from the uninitialized pass patched to show in more detail what's going on. Cycles can contribute to false positives. The chain length greater messages also show possible reasons for false positives in an unpatched GCC (the patched pass raises the limits to avoid them). The note after the warning shows the condition under which GCC determines the uninitialized variable is used (it needs improvement). Examining phi: cmd1_68 = PHI <cmd1_44(5), cmd1_12(4)> cycle detected cycle detected cycle detected chain length greater than 5: 6 chain length greater than 5: 6 chain length greater than 5: 6 chain length greater than 5: 6 chain length greater than 5: 6 cycle detected chain length greater than 5: 6 chain length greater than 5: 6 chain length greater than 5: 6 chain length greater than 5: 6 chain length greater than 5: 6 chain length greater than 5: 6 cycle detected cycle detected chain length greater than 5: 6 chain length greater than 5: 6 chain length greater than 5: 6 chain length greater than 5: 6 chain length greater than 5: 6 chain length greater than 5: 6 cycle detected cycle detected predicate::predicate (def_bb = 6, use_bb = 3, func_t) initialized from 9 dep_chains: 24 -> 8, 8 -> 9, 9 -> 26, 14 -> 15, 15 -> 32 24 -> 8, 8 -> 9, 9 -> 26, 14 -> 15, 15 -> 18 24 -> 8, 8 -> 9, 9 -> 26, 14 -> 15, 15 -> 19 24 -> 8, 8 -> 10, 10 -> 11, 11 -> 27, 14 -> 15, 15 -> 32 24 -> 8, 8 -> 10, 10 -> 11, 11 -> 27, 14 -> 15, 15 -> 18 24 -> 8, 8 -> 10, 10 -> 11, 11 -> 27, 14 -> 15, 15 -> 19 24 -> 8, 8 -> 10, 10 -> 13, 13 -> 30, 14 -> 15, 15 -> 32 24 -> 8, 8 -> 10, 10 -> 13, 13 -> 30, 14 -> 15, 15 -> 18 24 -> 8, 8 -> 10, 10 -> 13, 13 -> 30, 14 -> 15, 15 -> 19 init_from_control_deps { { 24 -> 8, 8 -> 9, 9 -> 26, 14 -> 15, 15 -> 32 }, { 24 -> 8, 8 -> 9, 9 -> 26, 14 -> 15, 15 -> 18 }, { 24 -> 8, 8 -> 9, 9 -> 26, 14 -> 15, 15 -> 19 }, { 24 -> 8, 8 -> 10, 10 -> 11, 11 -> 27, 14 -> 15, 15 -> 32 }, { 24 -> 8, 8 -> 10, 10 -> 11, 11 -> 27, 14 -> 15, 15 -> 18 }, { 24 -> 8, 8 -> 10, 10 -> 11, 11 -> 27, 14 -> 15, 15 -> 19 }, { 24 -> 8, 8 -> 10, 10 -> 13, 13 -> 30, 14 -> 15, 15 -> 32 }, { 24 -> 8, 8 -> 10, 10 -> 13, 13 -> 30, 14 -> 15, 15 -> 18 }, { 24 -> 8, 8 -> 10, 10 -> 13, 13 -> 30, 14 -> 15, 15 -> 19 } }: (empty) Found unguarded use in bb 3: cmd1_12 = PHI <cmd1_68(3), cmd1_19(D)(2)> cycle detected cycle detected cycle detected cycle detected cycle detected cycle detected chain length greater than 5: 6 chain length greater than 5: 6 chain length greater than 5: 6 chain length greater than 5: 6 chain length greater than 5: 6 cycle detected chain length greater than 5: 6 chain length greater than 5: 6 chain length greater than 5: 6 chain length greater than 5: 6 chain length greater than 5: 6 cycle detected chain length greater than 5: 6 chain length greater than 5: 6 chain length greater than 5: 6 chain length greater than 5: 6 chain length greater than 5: 6 chain length greater than 5: 6 cycle detected chain length greater than 5: 6 chain length greater than 5: 6 chain length greater than 5: 6 chain length greater than 5: 6 chain length greater than 5: 6 cycle detected cycle detected cycle detected chain length greater than 5: 6 chain length greater than 5: 6 chain length greater than 5: 6 chain length greater than 5: 6 chain length greater than 5: 6 cycle detected chain length greater than 5: 6 chain length greater than 5: 6 chain length greater than 5: 6 chain length greater than 5: 6 chain length greater than 5: 6 chain length greater than 5: 6 cycle detected chain length greater than 5: 6 chain length greater than 5: 6 chain length greater than 5: 6 chain length greater than 5: 6 chain length greater than 5: 6 cycle detected cycle detected cycle detected predicate::predicate (def_bb = 6, use_bb = 20, func_t) initialized from 3 dep_chains: 24 -> 8, 8 -> 9, 9 -> 26, 14 -> 15, 15 -> 20 24 -> 8, 8 -> 10, 10 -> 11, 11 -> 27, 14 -> 15, 15 -> 20 24 -> 8, 8 -> 10, 10 -> 13, 13 -> 30, 14 -> 15, 15 -> 20 init_from_control_deps { { 24 -> 8, 8 -> 9, 9 -> 26, 14 -> 15, 15 -> 20 }, { 24 -> 8, 8 -> 10, 10 -> 11, 11 -> 27, 14 -> 15, 15 -> 20 }, { 24 -> 8, 8 -> 10, 10 -> 13, 13 -> 30, 14 -> 15, 15 -> 20 } }: ((((MEM[(const char *)input_27 + -1B] != 101 && MEM[(const char *)input_27 + -1B] <= 101) && MEM[(const char *)input_27 + -1B] == 50) && MEM[(const char *)input_74 + 1B] == 10) && _72 == 101 || ((((MEM[(const char *)input_27 + -1B] != 101 && MEM[(const char *)input_27 + -1B] > 101) && MEM[(const char *)input_27 + -1B] <= 115) && MEM[(const char *)input_27 + -1B] > 112) && MEM[(const char *)input_74 + 1B] == 10) && _72 == 101) || ((((MEM[(const char *)input_27 + -1B] != 101 && MEM[(const char *)input_27 + -1B] > 101) && MEM[(const char *)input_27 + -1B] > 115) && MEM[(const char *)input_27 + -1B] == 118) && MEM[(const char *)input_74 + 1B] == 10) && _72 == 101 (expanded) OR (AND (NOT (_2 == 101), NOT (_2 > 101), _2 == 50, _4 == 10, _72 == 101), AND (NOT (_2 == 101), _2 > 101, NOT (_2 > 115), _2 > 112, _4 == 10, _72 == 101), AND (NOT (_2 == 101), _2 > 101, _2 > 115, _2 == 118, _4 == 10, _72 == 101)) collect_phi_def_edges for cd_root 4 and cmd1_68 = PHI <cmd1_44(5), cmd1_12(4)> Found def edge 5 -> 6 for cd_root 4 and operand 0 of: cmd1_68 = PHI <cmd1_44(5), cmd1_12(4)> Found def edge 3 -> 4 for cd_root 2 and operand 0 of: cmd1_12 = PHI <cmd1_68(3), cmd1_19(D)(2)> Found unguarded use in bb 20: _21 = cmd1_68 == 0; pr101770.c: In function ‘edit’: pr101770.c:50:18: warning: ‘cmd1’ may be used uninitialized in this function [-Wmaybe-uninitialized] 50 | return !cmd1; | ^~~~~ pr101770.c:7:11: note: used when ‘*(input+-1) != 'e' && *(input+-1) <= 'e' && *(input+-1) == '2' && input[1] == 10 && _72 = PHI <118(30), 50(26), _2(27)> == 'e' || *(input+-1) != 'e' && *(input+-1) > 'e' && *(input+-1) <= 's' && *(input+-1) > 'p' && input[1] == 10 && _72 = PHI <118(30), 50(26), _2(27)> == 'e' || *(input+-1) != 'e' && *(input+-1) > 'e' && *(input+-1) > 's' && *(input+-1) == 'v' && input[1] == 10 && _72 = PHI <118(30), 50(26), _2(27)> == 'e'’ 7 | int cmd1; | ^~~~ pr101770.c:7:11: note: ‘cmd1’ was declared here ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/101770] -Wmaybe-uninitialized false alarm with only locals in GNU diffutils 2021-08-03 23:50 [Bug tree-optimization/101770] New: -Wmaybe-uninitialized false alarm with only locals in GNU diffutils eggert at cs dot ucla.edu 2021-08-04 6:34 ` [Bug tree-optimization/101770] " rguenth at gcc dot gnu.org 2021-08-05 14:59 ` msebor at gcc dot gnu.org @ 2022-11-20 5:00 ` law at gcc dot gnu.org 2022-11-28 22:36 ` pinskia at gcc dot gnu.org ` (2 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: law at gcc dot gnu.org @ 2022-11-20 5:00 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101770 Jeffrey A. Law <law at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |FIXED Status|NEW |RESOLVED CC| |law at gcc dot gnu.org --- Comment #3 from Jeffrey A. Law <law at gcc dot gnu.org> --- Seems to be fixed on the trunk. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/101770] -Wmaybe-uninitialized false alarm with only locals in GNU diffutils 2021-08-03 23:50 [Bug tree-optimization/101770] New: -Wmaybe-uninitialized false alarm with only locals in GNU diffutils eggert at cs dot ucla.edu ` (2 preceding siblings ...) 2022-11-20 5:00 ` law at gcc dot gnu.org @ 2022-11-28 22:36 ` pinskia at gcc dot gnu.org 2023-05-19 21:16 ` eggert at cs dot ucla.edu 2023-05-19 21:44 ` eggert at cs dot ucla.edu 5 siblings, 0 replies; 7+ messages in thread From: pinskia at gcc dot gnu.org @ 2022-11-28 22:36 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101770 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |13.0 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/101770] -Wmaybe-uninitialized false alarm with only locals in GNU diffutils 2021-08-03 23:50 [Bug tree-optimization/101770] New: -Wmaybe-uninitialized false alarm with only locals in GNU diffutils eggert at cs dot ucla.edu ` (3 preceding siblings ...) 2022-11-28 22:36 ` pinskia at gcc dot gnu.org @ 2023-05-19 21:16 ` eggert at cs dot ucla.edu 2023-05-19 21:44 ` eggert at cs dot ucla.edu 5 siblings, 0 replies; 7+ messages in thread From: eggert at cs dot ucla.edu @ 2023-05-19 21:16 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101770 Paul Eggert <eggert at cs dot ucla.edu> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|FIXED |--- Status|RESOLVED |REOPENED Version|11.2.1 |13.1.1 --- Comment #4 from Paul Eggert <eggert at cs dot ucla.edu> --- I seeing the bug with gcc (GCC) 13.1.1 20230511 (Red Hat 13.1.1-2) on x86-64 when compiling GNU diffutils, so although the bug was reported fixed on the trunk last year, it appears that the fix hasn't propagated GCC 13 despite the Target Milestone being 13.0. The symptoms are: $ gcc -O2 -Wmaybe-uninitialized -S w.i w.i: In function ‘edit’: w.i:50:18: warning: ‘cmd1’ may be used uninitialized [-Wmaybe-uninitialized] 50 | return !cmd1; | ^~~~~ w.i:7:11: note: ‘cmd1’ was declared here 7 | int cmd1; | ^~~~ This appears to be the same bug as before so I am taking the liberty of reopening the bug report. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/101770] -Wmaybe-uninitialized false alarm with only locals in GNU diffutils 2021-08-03 23:50 [Bug tree-optimization/101770] New: -Wmaybe-uninitialized false alarm with only locals in GNU diffutils eggert at cs dot ucla.edu ` (4 preceding siblings ...) 2023-05-19 21:16 ` eggert at cs dot ucla.edu @ 2023-05-19 21:44 ` eggert at cs dot ucla.edu 5 siblings, 0 replies; 7+ messages in thread From: eggert at cs dot ucla.edu @ 2023-05-19 21:44 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101770 --- Comment #5 from Paul Eggert <eggert at cs dot ucla.edu> --- I can no longer reproduce the bug in bleeding-edge GNU diffutils, so this bug is not so important in its own right - that is, it's merely that GCC 13.1.1 still mishandles w.i. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-05-19 21:44 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-08-03 23:50 [Bug tree-optimization/101770] New: -Wmaybe-uninitialized false alarm with only locals in GNU diffutils eggert at cs dot ucla.edu 2021-08-04 6:34 ` [Bug tree-optimization/101770] " rguenth at gcc dot gnu.org 2021-08-05 14:59 ` msebor at gcc dot gnu.org 2022-11-20 5:00 ` law at gcc dot gnu.org 2022-11-28 22:36 ` pinskia at gcc dot gnu.org 2023-05-19 21:16 ` eggert at cs dot ucla.edu 2023-05-19 21:44 ` eggert at cs dot ucla.edu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).