public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/39666]  New: spurious warning with ranged-switch statements
@ 2009-04-06 18:14 dfranke at gcc dot gnu dot org
  2009-04-28 23:14 ` [Bug middle-end/39666] " pinskia at gcc dot gnu dot org
                   ` (11 more replies)
  0 siblings, 12 replies; 14+ messages in thread
From: dfranke at gcc dot gnu dot org @ 2009-04-06 18:14 UTC (permalink / raw)
  To: gcc-bugs

[Follow-up to http://gcc.gnu.org/ml/gcc/2009-04/msg00175.html]

$ cat range.f90
FUNCTION f(n)
  INTEGER, INTENT(in) :: n
  REAL                :: f

  SELECT CASE (n)
    CASE ( :-1);  f = -1.0
    CASE (0);     f =  0.0
    CASE (1: );   f =  1.0
  END SELECT
END FUNCTION

$> gfortran-svn -c -O -Wall -fdump-tree-original -fdump-tree-optimized
range.f90
range.f90: In function 'f':
range.f90:1: warning: '__result_f' may be used uninitialized in this function

The dump after optimization shows a 'default' clause that is never reached:
<bb 2>:
  switch (*n;) <default: <L6>, case -2147483648 ... -1: <L7>, case 0: L.3, case
1 ... 2147483647: L.4>


If above code is changed to
$ cat range.f90
FUNCTION f(n)
  INTEGER, INTENT(in) :: n
  REAL                :: f

  SELECT CASE (n)
    CASE ( :-1);  f = 0.0     ! was -1.0
    CASE (0);     f = 0.0
    CASE (1: );   f = 0.0     ! was  1.0
  END SELECT
END FUNCTION

$> gfortran-svn -c -O -Wall -fdump-tree-original -fdump-tree-optimized
range.f90
[no warning]

The dump after optimization shows:
f (integer(kind=4) & n)
{
<bb 2>:
  return 0.0;

}

The initial dump has the same structure for both cases (second case shown):
  switch (*n)
    {
      case -2147483648 ... -1:;
      __result_f = 0.0;
      goto L.1;
      case 0:;
      __result_f = 0.0;
      goto L.1;
      case 1 ... 2147483647:;
      __result_f = 0.0;
      goto L.1;
    }
  L.1:;

In the first case, somewhere during optimization a 'default' is added although
the whole range of an INTEGER(kind=4) is covered - which is found in the second
case.


-- 
           Summary: spurious warning with ranged-switch statements
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dfranke at gcc dot gnu dot org


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


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

* [Bug middle-end/39666] spurious warning with ranged-switch statements
  2009-04-06 18:14 [Bug middle-end/39666] New: spurious warning with ranged-switch statements dfranke at gcc dot gnu dot org
@ 2009-04-28 23:14 ` pinskia at gcc dot gnu dot org
  2009-04-29 11:52 ` jakub at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-04-28 23:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2009-04-28 23:14 -------
Confirmed.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-04-28 23:14:45
               date|                            |


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


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

* [Bug middle-end/39666] spurious warning with ranged-switch statements
  2009-04-06 18:14 [Bug middle-end/39666] New: spurious warning with ranged-switch statements dfranke at gcc dot gnu dot org
  2009-04-28 23:14 ` [Bug middle-end/39666] " pinskia at gcc dot gnu dot org
@ 2009-04-29 11:52 ` jakub at gcc dot gnu dot org
  2009-04-29 13:54 ` jakub at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu dot org @ 2009-04-29 11:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from jakub at gcc dot gnu dot org  2009-04-29 11:52 -------
In C:

int foo (int i)
{
  int j;
  switch (i)
    {
    case -__INT_MAX__ - 1 ... -1:
      j = 6;
      break;
    case 0:
      j = 5;
      break;
    case 1 ... __INT_MAX__:
      j = 4;
      break;
    }
  return j;
}

fails the same way.  The default label is added by gimplify_switch_expr.


-- 


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


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

* [Bug middle-end/39666] spurious warning with ranged-switch statements
  2009-04-06 18:14 [Bug middle-end/39666] New: spurious warning with ranged-switch statements dfranke at gcc dot gnu dot org
  2009-04-28 23:14 ` [Bug middle-end/39666] " pinskia at gcc dot gnu dot org
  2009-04-29 11:52 ` jakub at gcc dot gnu dot org
@ 2009-04-29 13:54 ` jakub at gcc dot gnu dot org
  2009-04-29 14:07 ` [Bug middle-end/39666] [4.3/4.4/4.5 Regression] " jakub at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu dot org @ 2009-04-29 13:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from jakub at gcc dot gnu dot org  2009-04-29 13:54 -------
Created an attachment (id=17778)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17778&action=view)
gcc44-pr39666.patch

Fix I'm going to bootstrap/regtest soon.


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jakub at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED


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


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

* [Bug middle-end/39666] [4.3/4.4/4.5 Regression] spurious warning with ranged-switch statements
  2009-04-06 18:14 [Bug middle-end/39666] New: spurious warning with ranged-switch statements dfranke at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2009-04-29 13:54 ` jakub at gcc dot gnu dot org
@ 2009-04-29 14:07 ` jakub at gcc dot gnu dot org
  2009-04-29 14:18 ` rguenth at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu dot org @ 2009-04-29 14:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jakub at gcc dot gnu dot org  2009-04-29 14:07 -------
This is a regression from 3.4.x to 4.0.x BTW.


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|spurious warning with       |[4.3/4.4/4.5 Regression]
                   |ranged-switch statements    |spurious warning with
                   |                            |ranged-switch statements
   Target Milestone|---                         |4.3.4


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


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

* [Bug middle-end/39666] [4.3/4.4/4.5 Regression] spurious warning with ranged-switch statements
  2009-04-06 18:14 [Bug middle-end/39666] New: spurious warning with ranged-switch statements dfranke at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2009-04-29 14:07 ` [Bug middle-end/39666] [4.3/4.4/4.5 Regression] " jakub at gcc dot gnu dot org
@ 2009-04-29 14:18 ` rguenth at gcc dot gnu dot org
  2009-05-05 16:08 ` mmitchel at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-04-29 14:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rguenth at gcc dot gnu dot org  2009-04-29 14:17 -------
With -O2 VRP should (since 4.4) "fix" this as well.  That said, newer GCC
no longer need a default label.


-- 


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


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

* [Bug middle-end/39666] [4.3/4.4/4.5 Regression] spurious warning with ranged-switch statements
  2009-04-06 18:14 [Bug middle-end/39666] New: spurious warning with ranged-switch statements dfranke at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2009-04-29 14:18 ` rguenth at gcc dot gnu dot org
@ 2009-05-05 16:08 ` mmitchel at gcc dot gnu dot org
  2009-05-05 21:09 ` jakub at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2009-05-05 16:08 UTC (permalink / raw)
  To: gcc-bugs



-- 

mmitchel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2


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


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

* [Bug middle-end/39666] [4.3/4.4/4.5 Regression] spurious warning with ranged-switch statements
  2009-04-06 18:14 [Bug middle-end/39666] New: spurious warning with ranged-switch statements dfranke at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2009-05-05 16:08 ` mmitchel at gcc dot gnu dot org
@ 2009-05-05 21:09 ` jakub at gcc dot gnu dot org
  2009-05-12 16:19 ` jakub at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu dot org @ 2009-05-05 21:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from jakub at gcc dot gnu dot org  2009-05-05 21:09 -------
Subject: Bug 39666

Author: jakub
Date: Tue May  5 21:09:16 2009
New Revision: 147136

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=147136
Log:
        PR middle-end/39666
        * gimplify.c (gimplify_switch_expr): If case labels cover the whole
        range of the type, but default label is missing, add it with one
        of the existing labels instead of adding a new label for it.

        * gcc.dg/pr39666-1.c: New test.
        * gcc.dg/pr39666-2.c: Likewise.
        * g++.dg/warn/Wuninitialized-4.C: Likewise.
        * g++.dg/warn/Wuninitialized-5.C: Likewise.
        * gfortran.dg/pr39666-1.f90: Likewise.
        * gfortran.dg/pr39666-2.f90: Likewise.

Added:
    trunk/gcc/testsuite/g++.dg/warn/Wuninitialized-4.C
    trunk/gcc/testsuite/g++.dg/warn/Wuninitialized-5.C
    trunk/gcc/testsuite/gcc.dg/pr39666-1.c
    trunk/gcc/testsuite/gcc.dg/pr39666-2.c
    trunk/gcc/testsuite/gfortran.dg/pr39666-1.f90
    trunk/gcc/testsuite/gfortran.dg/pr39666-2.f90
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/gimplify.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug middle-end/39666] [4.3/4.4/4.5 Regression] spurious warning with ranged-switch statements
  2009-04-06 18:14 [Bug middle-end/39666] New: spurious warning with ranged-switch statements dfranke at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2009-05-05 21:09 ` jakub at gcc dot gnu dot org
@ 2009-05-12 16:19 ` jakub at gcc dot gnu dot org
  2009-05-12 16:24 ` [Bug middle-end/39666] [4.3 " jakub at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu dot org @ 2009-05-12 16:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from jakub at gcc dot gnu dot org  2009-05-12 16:19 -------
Subject: Bug 39666

Author: jakub
Date: Tue May 12 16:19:29 2009
New Revision: 147440

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=147440
Log:
        PR middle-end/39666
        * gimplify.c (gimplify_switch_expr): If case labels cover the whole
        range of the type, but default label is missing, add it with one
        of the existing labels instead of adding a new label for it.

        * gcc.dg/pr39666-1.c: New test.
        * gcc.dg/pr39666-2.c: Likewise.
        * g++.dg/warn/Wuninitialized-4.C: Likewise.
        * g++.dg/warn/Wuninitialized-5.C: Likewise.
        * gfortran.dg/pr39666-1.f90: Likewise.
        * gfortran.dg/pr39666-2.f90: Likewise.

Added:
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/warn/Wuninitialized-4.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/warn/Wuninitialized-5.C
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/pr39666-1.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/pr39666-2.c
    branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/pr39666-1.f90
    branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/pr39666-2.f90
Modified:
    branches/gcc-4_4-branch/gcc/ChangeLog
    branches/gcc-4_4-branch/gcc/gimplify.c
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug middle-end/39666] [4.3 Regression] spurious warning with ranged-switch statements
  2009-04-06 18:14 [Bug middle-end/39666] New: spurious warning with ranged-switch statements dfranke at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2009-05-12 16:19 ` jakub at gcc dot gnu dot org
@ 2009-05-12 16:24 ` jakub at gcc dot gnu dot org
  2009-08-04 12:48 ` rguenth at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu dot org @ 2009-05-12 16:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from jakub at gcc dot gnu dot org  2009-05-12 16:24 -------
Fixed for 4.4/4.5 so far.


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[4.3/4.4/4.5 Regression]    |[4.3 Regression] spurious
                   |spurious warning with       |warning with ranged-switch
                   |ranged-switch statements    |statements


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


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

* [Bug middle-end/39666] [4.3 Regression] spurious warning with ranged-switch statements
  2009-04-06 18:14 [Bug middle-end/39666] New: spurious warning with ranged-switch statements dfranke at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2009-05-12 16:24 ` [Bug middle-end/39666] [4.3 " jakub at gcc dot gnu dot org
@ 2009-08-04 12:48 ` rguenth at gcc dot gnu dot org
  2009-12-04 22:48 ` dfranke at gcc dot gnu dot org
  2010-05-22 18:31 ` rguenth at gcc dot gnu dot org
  11 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-08-04 12:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from rguenth at gcc dot gnu dot org  2009-08-04 12:30 -------
GCC 4.3.4 is being released, adjusting target milestone.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.3.4                       |4.3.5


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


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

* [Bug middle-end/39666] [4.3 Regression] spurious warning with ranged-switch statements
  2009-04-06 18:14 [Bug middle-end/39666] New: spurious warning with ranged-switch statements dfranke at gcc dot gnu dot org
                   ` (9 preceding siblings ...)
  2009-08-04 12:48 ` rguenth at gcc dot gnu dot org
@ 2009-12-04 22:48 ` dfranke at gcc dot gnu dot org
  2010-05-22 18:31 ` rguenth at gcc dot gnu dot org
  11 siblings, 0 replies; 14+ messages in thread
From: dfranke at gcc dot gnu dot org @ 2009-12-04 22:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from dfranke at gcc dot gnu dot org  2009-12-04 22:47 -------
Jakub, do you still plan to bring this to 4.3?


-- 


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


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

* [Bug middle-end/39666] [4.3 Regression] spurious warning with ranged-switch statements
  2009-04-06 18:14 [Bug middle-end/39666] New: spurious warning with ranged-switch statements dfranke at gcc dot gnu dot org
                   ` (10 preceding siblings ...)
  2009-12-04 22:48 ` dfranke at gcc dot gnu dot org
@ 2010-05-22 18:31 ` rguenth at gcc dot gnu dot org
  11 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-05-22 18:31 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from rguenth at gcc dot gnu dot org  2010-05-22 18:13 -------
GCC 4.3.5 is being released, adjusting target milestone.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.3.5                       |4.3.6


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


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

* [Bug middle-end/39666] [4.3 Regression] spurious warning with ranged-switch statements
       [not found] <bug-39666-4@http.gcc.gnu.org/bugzilla/>
@ 2011-06-27 12:03 ` rguenth at gcc dot gnu.org
  0 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-06-27 12:03 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|4.3.6                       |4.4.2

--- Comment #12 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-06-27 11:50:35 UTC ---
Fixed for 4.4.2.


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

end of thread, other threads:[~2011-06-27 12:03 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-06 18:14 [Bug middle-end/39666] New: spurious warning with ranged-switch statements dfranke at gcc dot gnu dot org
2009-04-28 23:14 ` [Bug middle-end/39666] " pinskia at gcc dot gnu dot org
2009-04-29 11:52 ` jakub at gcc dot gnu dot org
2009-04-29 13:54 ` jakub at gcc dot gnu dot org
2009-04-29 14:07 ` [Bug middle-end/39666] [4.3/4.4/4.5 Regression] " jakub at gcc dot gnu dot org
2009-04-29 14:18 ` rguenth at gcc dot gnu dot org
2009-05-05 16:08 ` mmitchel at gcc dot gnu dot org
2009-05-05 21:09 ` jakub at gcc dot gnu dot org
2009-05-12 16:19 ` jakub at gcc dot gnu dot org
2009-05-12 16:24 ` [Bug middle-end/39666] [4.3 " jakub at gcc dot gnu dot org
2009-08-04 12:48 ` rguenth at gcc dot gnu dot org
2009-12-04 22:48 ` dfranke at gcc dot gnu dot org
2010-05-22 18:31 ` rguenth at gcc dot gnu dot org
     [not found] <bug-39666-4@http.gcc.gnu.org/bugzilla/>
2011-06-27 12:03 ` rguenth at gcc dot gnu.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).