[Bug c++/20008] [4.0 Regression] internal compiler error: in expand_case, at stmt.c:2397

2005-02-18 Thread cvs-commit at gcc dot gnu dot org

--- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-02-18 
12:21 ---
Subject: Bug 20008

CVSROOT:/cvs/gcc
Module name:gcc
Changes by: [EMAIL PROTECTED]   2005-02-18 12:20:50

Modified files:
gcc: ChangeLog stmt.c 
gcc/testsuite  : ChangeLog 
Added files:
gcc/testsuite/g++.dg/opt: switch4.C 

Log message:
gcc/ChangeLog:
PR c++/20008
* stmt.c (expand_case): Don't assume cleanup_tree_cfg will remove
cases that are out-of-range for the index type.
gcc/testsuite/ChangeLog:
PR c++/20008
* g++.dg/opt/switch4.C: New.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gccr1=2.7522r2=2.7523
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/stmt.c.diff?cvsroot=gccr1=1.415r2=1.416
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gccr1=1.5046r2=1.5047
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/opt/switch4.C.diff?cvsroot=gccr1=NONEr2=1.1



-- 


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


[Bug c++/20008] [4.0 Regression] internal compiler error: in expand_case, at stmt.c:2397

2005-02-18 Thread jakub at gcc dot gnu dot org

--- Additional Comments From jakub at gcc dot gnu dot org  2005-02-18 12:26 
---
Fixed.

-- 
   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution||FIXED


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


[Bug c++/20008] [4.0 Regression] internal compiler error: in expand_case, at stmt.c:2397

2005-02-17 Thread caolanm at redhat dot com

--- Additional Comments From caolanm at redhat dot com  2005-02-17 10:00 
---
FWIW: openoffice.org 1.9.77 side patch to workaround at
http://people.redhat.com/caolanm/gcc4/xmlsecurity.gcc20008.gcc4.patch

-- 


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


[Bug c++/20008] [4.0 Regression] internal compiler error: in expand_case, at stmt.c:2397

2005-02-17 Thread aoliva at gcc dot gnu dot org


-- 
   What|Removed |Added

 AssignedTo|unassigned at gcc dot gnu   |aoliva at gcc dot gnu dot
   |dot org |org
 Status|NEW |ASSIGNED
   Last reconfirmed|2005-02-16 19:16:58 |2005-02-17 15:13:15
   date||


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


[Bug c++/20008] [4.0 Regression] internal compiler error: in expand_case, at stmt.c:2397

2005-02-17 Thread aoliva at redhat dot com

--- Additional Comments From aoliva at gcc dot gnu dot org  2005-02-17 
16:17 ---
Subject: [PR c++/20008, middle-end] handle switch with all cases out-of-range

Sure enough, the testcase relied on undefined behavior, but that's no
reason for us to ICE at compile time.  I suppose it might be nice to
get the tree cfg cleanup code to detect that it can discard cases that
are out of range, but I'm not all that familiar with the cfg cleanup
code, so I figured I'd try this first.

Ok to install if regression testing passes on x86_64-linux-gnu?

Index: gcc/ChangeLog
from  Alexandre Oliva  [EMAIL PROTECTED]

PR c++/20008
* stmt.c (expand_case): Don't assume cleanup_tree_cfg will remove
cases that are out-of-range for the index type.

Index: gcc/stmt.c
===
RCS file: /cvs/gcc/gcc/gcc/stmt.c,v
retrieving revision 1.412
diff -u -p -r1.412 stmt.c
--- gcc/stmt.c 13 Dec 2004 16:03:38 - 1.412
+++ gcc/stmt.c 17 Feb 2005 16:12:31 -
@@ -1,6 +1,7 @@
 /* Expands front end tree to back end RTL for GCC
Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997,
-   1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+   1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+ Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -2393,8 +2394,14 @@ expand_case (tree exp)
   BITMAP_XFREE (label_bitmap);
 
   /* cleanup_tree_cfg removes all SWITCH_EXPR with a single
-destination, such as one with a default case only.  */
-  gcc_assert (count != 0);
+destination, such as one with a default case only.  However,
+it doesn't remove cases that are out of range for the switch
+type, so we may still get a zero here.  */
+  if (count == 0)
+   {
+ emit_jump (default_label);
+ return;
+   }
 
   /* Compute span of values.  */
   range = fold (build2 (MINUS_EXPR, index_type, maxval, minval));
Index: gcc/testsuite/ChangeLog
from  Alexandre Oliva  [EMAIL PROTECTED]

PR c++/20008
* g++.dg/opt/switch3.C: New.

Index: gcc/testsuite/g++.dg/opt/switch3.C
===
RCS file: gcc/testsuite/g++.dg/opt/switch3.C
diff -N gcc/testsuite/g++.dg/opt/switch3.C
--- /dev/null   1 Jan 1970 00:00:00 -
+++ gcc/testsuite/g++.dg/opt/switch3.C 17 Feb 2005 16:12:45 -
@@ -0,0 +1,30 @@
+// { dg-do compile }
+
+// PR c++/20008
+
+// We failed to compile this because CFG cleanup left the switch
+// statement intact, whereas expand_case expected at least one
+// in-range case to remain.
+
+typedef enum _SECStatus {
+  SECWouldBlock = -2,
+  SECFailure = -1,
+  SECSuccess = 0
+} SECStatus;
+
+typedef enum {
+  SEC_ERROR_BAD_SIGNATURE = (-0x2000) + 10
+} SECErrorCodes;
+
+void g(void);
+void f(SECStatus status)
+{
+  switch( status )
+{
+case SEC_ERROR_BAD_SIGNATURE :
+  // This case can be optimized away in C++ (but apparently not in
+  // C), because the enum type is defined with a narrow range.
+  g();
+  break ;
+}
+}

-- 
Alexandre Oliva http://www.ic.unicamp.br/~oliva/
Red Hat Compiler Engineer   [EMAIL PROTECTED], gcc.gnu.org}
Free Software Evangelist  [EMAIL PROTECTED], gnu.org}


-- 


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


[Bug c++/20008] [4.0 Regression] internal compiler error: in expand_case, at stmt.c:2397

2005-02-16 Thread pinskia at gcc dot gnu dot org


-- 
   What|Removed |Added

   Keywords||ice-on-valid-code
Summary|internal compiler error: in |[4.0 Regression] internal
   |expand_case, at stmt.c:2397 |compiler error: in
   ||expand_case, at stmt.c:2397
   Target Milestone|--- |4.0.0


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


[Bug c++/20008] [4.0 Regression] internal compiler error: in expand_case, at stmt.c:2397

2005-02-16 Thread pinskia at gcc dot gnu dot org

--- Additional Comments From pinskia at gcc dot gnu dot org  2005-02-16 
19:16 ---
Reduced testcase:
typedef enum _SECStatus {
  SECWouldBlock = -2,
  SECFailure = -1,
  SECSuccess = 0
} SECStatus;
typedef enum {
  SEC_ERROR_BAD_SIGNATURE = (-0x2000) + 10
} SECErrorCodes;
void g(void);
void f(SECStatus status)
{
  switch( status )
  {
case SEC_ERROR_BAD_SIGNATURE :
  g();
  break ;
  }
}
: Search converges between 2004-10-25-161001-trunk (#610) and 
2004-10-26-161001-trunk 
(#611).

This is undefined code (as SEC_ERROR_BAD_SIGNATURE is out of the range of 
SECStatus).  Enums are 
defined differently in C++ than C.

-- 
   What|Removed |Added

 Status|UNCONFIRMED |NEW
  Component|middle-end  |c++
 Ever Confirmed||1
   Last reconfirmed|-00-00 00:00:00 |2005-02-16 19:16:58
   date||


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