public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "msebor at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/101770] -Wmaybe-uninitialized false alarm with only locals in GNU diffutils
Date: Thu, 05 Aug 2021 14:59:50 +0000	[thread overview]
Message-ID: <bug-101770-4-swYUhSX3S8@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-101770-4@http.gcc.gnu.org/bugzilla/>

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

  parent reply	other threads:[~2021-08-05 14:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-03 23:50 [Bug tree-optimization/101770] New: " 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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-101770-4-swYUhSX3S8@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).