From d47a5ab185811d06aab4e614d6b9cca636aedb1a Mon Sep 17 00:00:00 2001 From: aoliva Date: Fri, 18 Feb 2005 12:20:49 +0000 Subject: 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@95225 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/stmt.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'gcc/stmt.c') diff --git a/gcc/stmt.c b/gcc/stmt.c index a438532b11b..64e070b5a0a 100644 --- a/gcc/stmt.c +++ b/gcc/stmt.c @@ -2394,8 +2394,14 @@ expand_case (tree exp) BITMAP_FREE (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)); -- cgit v1.2.1