--- gcc/fortran/trans-stmt.c	2010-07-14 22:36:16.000000000 +0200
+++ gcc/fortran/trans-stmt.c	2010-07-14 22:21:29.000000000 +0200
@@ -1806,8 +1806,9 @@
         {
 	  label = gfc_build_label_decl (NULL_TREE);
 	  tmp = fold_build3 (CASE_LABEL_EXPR, void_type_node,
-			     build_int_cst (NULL_TREE, d->n),
-			     build_int_cst (NULL_TREE, d->n), label);
+			     (d->low == NULL && d->high == NULL)
+			     ? NULL : build_int_cst (NULL_TREE, d->n),
+			     NULL, label);
           gfc_add_expr_to_block (&body, tmp);
         }
 
--- gcc/testsuite/gfortran.dg/select_char_3.f90.jj	2010-07-14 22:40:59.000000000 +0200
+++ gcc/testsuite/gfortran.dg/select_char_3.f90	2010-07-14 22:33:33.000000000 +0200
@@ -0,0 +1,15 @@
+! PR fortran/40206
+! { dg-do compile }
+! { dg-options "-O2 -Wuninitialized" }
+
+function char2type (char)
+  character, intent(in) :: char
+  integer :: char2type
+
+  select case (char)
+    case ('E','e')
+      char2type=1
+    case default
+      char2type=-1234
+  end select
+end function
