public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/11270] New: [tree-ssa] Strange warning with -Wunreachable-code.
@ 2003-06-20 18:45 reichelt at gcc dot gnu dot org
  2003-06-20 19:12 ` [Bug c/11270] " pinskia at physics dot uc dot edu
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2003-06-20 18:45 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11270

           Summary: [tree-ssa] Strange warning with -Wunreachable-code.
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: reichelt@gcc.gnu.org
                CC: dnovillo@gcc.gnu.org,gcc-bugs@gcc.gnu.org
  GCC host triplet: i686-pc-linux-gnu

This is actually the same bug as in PR8828, but this time for the
tree-ssa-branch (as of 20030620). Compiling the following code with
"gcc -Wunreachable-code -c"

-------------------------------------------
void foo(int i)
{
  switch(i)
  {
    case 0:
      break;
    case 1:
      break;
  }
}
-------------------------------------------

I get the following strange warning:

warn.c: In function `void foo(int)':
warn.c:7: warning: will never be executed
warn.c:4: warning: will never be executed


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c/11270] [tree-ssa] Strange warning with -Wunreachable-code.
  2003-06-20 18:45 [Bug c/11270] New: [tree-ssa] Strange warning with -Wunreachable-code reichelt at gcc dot gnu dot org
@ 2003-06-20 19:12 ` pinskia at physics dot uc dot edu
  2003-06-20 19:12 ` pinskia at physics dot uc dot edu
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-06-20 19:12 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11270


pinskia at physics dot uc dot edu changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2003-06-20 19:11:13
               date|                            |


------- Additional Comments From pinskia at physics dot uc dot edu  2003-06-20 19:11 -------
This really looks like a back-end problem rather than a tree-ssa problem because the rtl 
does not contain any thing that might not be executed as my previous comment says.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c/11270] [tree-ssa] Strange warning with -Wunreachable-code.
  2003-06-20 18:45 [Bug c/11270] New: [tree-ssa] Strange warning with -Wunreachable-code reichelt at gcc dot gnu dot org
  2003-06-20 19:12 ` [Bug c/11270] " pinskia at physics dot uc dot edu
@ 2003-06-20 19:12 ` pinskia at physics dot uc dot edu
  2003-06-20 19:27 ` pinskia at physics dot uc dot edu
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-06-20 19:12 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11270



------- Additional Comments From pinskia at physics dot uc dot edu  2003-06-20 19:09 -------
Created an attachment (id=4258)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=4258&action=view)
rtl on powerpc-apple-darwin6.6

The warning is in a difference place for powerpc-apple-darwin6.6:
pr11270.c: In function `foo':
pr11270.c:5: warning: will never be executed

The rtl loos like (on powerpc-apple-darwin6.6 with tree-ssa branch on
20030617):
  r118 = i
  r119 = r118 == 0
  if (r119==0) jmp label_ref10;
  jmp label_ref16
label_ref10:
  jmp label_ref21
label_ref16:
label_ref21:


Looks like a back-end bug rather than one caused by the trees.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c/11270] [tree-ssa] Strange warning with -Wunreachable-code.
  2003-06-20 18:45 [Bug c/11270] New: [tree-ssa] Strange warning with -Wunreachable-code reichelt at gcc dot gnu dot org
  2003-06-20 19:12 ` [Bug c/11270] " pinskia at physics dot uc dot edu
  2003-06-20 19:12 ` pinskia at physics dot uc dot edu
@ 2003-06-20 19:27 ` pinskia at physics dot uc dot edu
  2003-06-21  1:31 ` bangerth at dealii dot org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-06-20 19:27 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11270



------- Additional Comments From pinskia at physics dot uc dot edu  2003-06-20 19:25 -------
Looks like if there is only a note that gets the warning, maybe if there is no code on this line do 
not emit the note?


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c/11270] [tree-ssa] Strange warning with -Wunreachable-code.
  2003-06-20 18:45 [Bug c/11270] New: [tree-ssa] Strange warning with -Wunreachable-code reichelt at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2003-06-20 19:27 ` pinskia at physics dot uc dot edu
@ 2003-06-21  1:31 ` bangerth at dealii dot org
  2003-08-03 19:33 ` [Bug middle-end/11270] " pinskia at physics dot uc dot edu
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: bangerth at dealii dot org @ 2003-06-21  1:31 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11270


bangerth at dealii dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.4                         |tree-ssa


------- Additional Comments From bangerth at dealii dot org  2003-06-21 01:28 -------
Bulk switch target milestone for all PRs with [tree-ssa] in the summary to
have milestone=tree-ssa.
W.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/11270] [tree-ssa] Strange warning with -Wunreachable-code.
  2003-06-20 18:45 [Bug c/11270] New: [tree-ssa] Strange warning with -Wunreachable-code reichelt at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2003-06-21  1:31 ` bangerth at dealii dot org
@ 2003-08-03 19:33 ` pinskia at physics dot uc dot edu
  2003-08-15  3:37 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-08-03 19:33 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11270


pinskia at physics dot uc dot edu changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2003-07-07 01:29:23         |2003-08-03 19:33:21
               date|                            |


------- Additional Comments From pinskia at physics dot uc dot edu  2003-08-03 19:33 -------
The error message is even worse now:
pr11270.c: In function `foo':
:5439488: warning: will never be executed
pr11270.c:5: warning: will never be executed


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/11270] [tree-ssa] Strange warning with -Wunreachable-code.
  2003-06-20 18:45 [Bug c/11270] New: [tree-ssa] Strange warning with -Wunreachable-code reichelt at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2003-08-03 19:33 ` [Bug middle-end/11270] " pinskia at physics dot uc dot edu
@ 2003-08-15  3:37 ` pinskia at gcc dot gnu dot org
  2003-09-14 21:41 ` steven at gcc dot gnu dot org
  2003-11-13 23:11 ` steven at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-08-15  3:37 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11270


pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2003-08-03 19:33:21         |2003-08-15 03:37:06
               date|                            |


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-08-15 03:37 -------
Looks like the line number and file name has been resulved:
pr11370.c: In function `foo':
pr11370.c:8: warning: will never be executed
pr11370.c:6: warning: will never be executed
But the problem still exists.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/11270] [tree-ssa] Strange warning with -Wunreachable-code.
  2003-06-20 18:45 [Bug c/11270] New: [tree-ssa] Strange warning with -Wunreachable-code reichelt at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2003-08-15  3:37 ` pinskia at gcc dot gnu dot org
@ 2003-09-14 21:41 ` steven at gcc dot gnu dot org
  2003-11-13 23:11 ` steven at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: steven at gcc dot gnu dot org @ 2003-09-14 21:41 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11270


steven at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2003-08-15 03:37:06         |2003-09-14 21:10:03
               date|                            |


------- Additional Comments From steven at gcc dot gnu dot org  2003-09-14 21:10 -------
Analysis of this bug: never_reached_warning() is just plain stupid.  Lemme tell
you why:

>From mainline:

(jump_insn 19 18 20 (set (pc)
        (if_then_else (eq (reg:CCZ 17 flags)
                (const_int 0 [0x0]))
            (label_ref 11)
            (pc))) -1 (nil)
    (nil))
                                                                                
(jump_insn 20 19 21 (set (pc)
        (label_ref 17)) -1 (nil)
    (nil))
                                                                                
(barrier 21 20 9)
                                                                                
(note 9 21 10 NOTE_INSN_DELETED)
                                                                                
(note 10 9 11 NOTE_INSN_DELETED)
                                                                                
(code_label 11 10 12 3 "" [0 uses])

(note 12 11 13 [ 20 0 ]  NOTE_INSN_PREDICTION)
                                                                                
(note 13 12 14 ("t.c") 6)
                                                                                
(jump_insn 14 13 15 (set (pc)
        (label_ref 22)) -1 (nil)
    (nil))
                                                                                
(barrier 15 14 16)


>From tree-ssa:
(jump_insn 18 17 19 (set (pc)
        (if_then_else (eq (reg:CCZ 17 flags)
                (const_int 0 [0x0]))
            (label_ref 10)
            (pc))) -1 (nil)
    (nil))
                                                                                
(jump_insn 19 18 20 (set (pc)
        (label_ref 16)) -1 (nil)
    (nil))
                                                                                
(barrier 20 19 9)
                                                                                
(note 9 20 10 ("t.c") 5)
                                                                                
(code_label 10 9 11 2 "" [0 uses])
                                                                                
(note 11 10 12 ("t.c") 6)
                                                                                
(jump_insn 12 11 13 (set (pc)
        (label_ref 21)) -1 (nil)
    (nil))
                                                                                
(barrier 13 12 14)



Note the extra line note we emit in tree-ssa before the code_label. This fools
jump.c:never_reached_warning() into thinking that this "unreachable" block, that
in reality is simply removed because the switch body is empty, has more than two
statements in it: two_avoided_lines == true, and you get the warning. Yes, it's
true, never_reached_warning() relies on line notes...

Conclusion: -Wunreachable-code is broken in all sorts of ways.

It's funny to see that such a seemingly trivial warning can cause so many PRs. I
think this is the fourth or fifth or something that I've analyzed in about a
years' time...

I am tempted to suspend this one until one or both of the following ideas get
implemented:

- Mark Mitchell says we should just whack -Wunreachable-code as it
  is now, and only warn for obviously unreachable code in the front
  ends, i.e. the middle end should not issue the warning, and the
  code that you'd warn about don't need CFG information.
  (I like the idea for a trivial -Wunreachable-code, but I'd also
   like to keep a CFG-based approach. The first could maybe turned
   on by default with -Wextra...)
- Remove all the "-Wunreachable-code"-code entirely from jump.c on
  the tree-ssa branch and re-implement it based on the tree-cfg.
  (I don't recall this ever being discussed, but it seems like an
   obvious and not-too-hard-to-implement solution..)

Thoughts?

P.S.
The irony is that this actually is an improvement. Mainline does not put out a
line note for the case label, but tree-ssa does :-)


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/11270] [tree-ssa] Strange warning with -Wunreachable-code.
  2003-06-20 18:45 [Bug c/11270] New: [tree-ssa] Strange warning with -Wunreachable-code reichelt at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2003-09-14 21:41 ` steven at gcc dot gnu dot org
@ 2003-11-13 23:11 ` steven at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: steven at gcc dot gnu dot org @ 2003-11-13 23:11 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From steven at gcc dot gnu dot org  2003-11-13 23:10 -------
Misteriously fixed by the new statement chaining code.  Can we have more of 
that please? 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11270


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2003-11-13 23:11 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-20 18:45 [Bug c/11270] New: [tree-ssa] Strange warning with -Wunreachable-code reichelt at gcc dot gnu dot org
2003-06-20 19:12 ` [Bug c/11270] " pinskia at physics dot uc dot edu
2003-06-20 19:12 ` pinskia at physics dot uc dot edu
2003-06-20 19:27 ` pinskia at physics dot uc dot edu
2003-06-21  1:31 ` bangerth at dealii dot org
2003-08-03 19:33 ` [Bug middle-end/11270] " pinskia at physics dot uc dot edu
2003-08-15  3:37 ` pinskia at gcc dot gnu dot org
2003-09-14 21:41 ` steven at gcc dot gnu dot org
2003-11-13 23:11 ` steven at gcc dot gnu dot org

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).