re PR middle-end/18965 (ICE in gimplify_init_ctor_eval)
authorAndrew Pinski <pinskia@physics.uc.edu>
Tue, 14 Dec 2004 20:13:16 +0000 (20:13 +0000)
committerAndrew Pinski <pinskia@gcc.gnu.org>
Tue, 14 Dec 2004 20:13:16 +0000 (12:13 -0800)
2004-12-14  Andrew Pinski  <pinskia@physics.uc.edu>

        PR c++/18965
        * init.c (build_zero_init): If the max_index is 0, there is no
        need to create a RANGE_EXPR.

2004-12-14  Andrew Pinski  <pinskia@physics.uc.edu>

        PR c++/18965
        * g++.dg/init/array17.C: New test.

From-SVN: r92158

gcc/cp/ChangeLog
gcc/cp/init.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/init/array17.C [new file with mode: 0644]

index 4b2f677a29048a511f23e5f0c21bef91575f791f..ef5462859d97fe8f440bc2dac1fd1f3d2c7a5750 100644 (file)
@@ -1,3 +1,9 @@
+2004-12-14  Andrew Pinski  <pinskia@physics.uc.edu>
+
+       PR c++/18965
+       * init.c (build_zero_init): If the max_index is 0, there is no
+       need to create a RANGE_EXPR.
+
 2004-12-14  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/18793
index 70703efacacd0fe244f8729288b88ee234d737c2..a1a404c53f9a9fc8d76db9cde10ea5cecdab76e1 100644 (file)
@@ -231,8 +231,13 @@ build_zero_init (tree type, tree nelts, bool static_storage_p)
          tree elt_init = build_zero_init (TREE_TYPE (type),
                                           /*nelts=*/NULL_TREE,
                                           static_storage_p);
-         tree range = build2 (RANGE_EXPR,
-                              sizetype, size_zero_node, max_index);
+         tree range;
+         
+         /* If this is a one element array, we just use a regular init.  */
+         if (tree_int_cst_equal (size_zero_node, max_index))
+           range = size_zero_node;
+         else
+          range = build2 (RANGE_EXPR, sizetype, size_zero_node, max_index);
          
          inits = tree_cons (range, elt_init, inits);
        }
index b92d0a5d0abc424642575aef05d1b5aab7e33a11..72443ba5246b5ea2508caa4c747320c8f50669b8 100644 (file)
@@ -1,3 +1,8 @@
+2004-12-14  Andrew Pinski  <pinskia@physics.uc.edu>
+
+       PR c++/18965
+       * g++.dg/init/array17.C: New test.
+
 2004-12-14  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/18793
diff --git a/gcc/testsuite/g++.dg/init/array17.C b/gcc/testsuite/g++.dg/init/array17.C
new file mode 100644 (file)
index 0000000..7fdb196
--- /dev/null
@@ -0,0 +1,5 @@
+class StringMap { 
+  const char empty_str[1]; 
+public: 
+  StringMap() : empty_str() {} 
+};