diff mbox

C++ PATCH to C++1y VLA of 0 length

Message ID 5271401D.6050005@redhat.com
State New
Headers show

Commit Message

Jason Merrill Oct. 30, 2013, 5:21 p.m. UTC
At the Chicago meeting the EWG agreed that we don't need to throw on 
0-length VLAs.

Tested x86_64-pc-linux-gnu, applying to trunk.
diff mbox

Patch

commit 1e328cbd26bfb641db8e218e4a4c32fc1a9a8d9d
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Oct 25 06:15:01 2013 -0400

    	* decl.c (cp_finish_decl): Never throw for VLA bound == 0.

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 1e92f2a..476d559 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -6404,11 +6404,7 @@  cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
       /* If the VLA bound is larger than half the address space, or less
 	 than zero, throw std::bad_array_length.  */
       tree max = convert (ssizetype, TYPE_MAX_VALUE (TYPE_DOMAIN (type)));
-      /* C++1y says we should throw for length <= 0, but we have
-	 historically supported zero-length arrays.  Let's treat that as an
-	 extension to be disabled by -std=c++NN.  */
-      int lower = flag_iso ? 0 : -1;
-      tree comp = build2 (LT_EXPR, boolean_type_node, max, ssize_int (lower));
+      tree comp = build2 (LT_EXPR, boolean_type_node, max, ssize_int (-1));
       comp = build3 (COND_EXPR, void_type_node, comp,
 		     throw_bad_array_length (), void_zero_node);
       finish_expr_stmt (comp);