[Mesa-stable] [PATCH 3/4] glsl: No compile error for out of bounds array index

Anuj Phogat anuj.phogat at gmail.com
Mon Sep 22 15:57:39 PDT 2014


Emit a warning to let user know that the behavior is undefined.

Cc: <mesa-stable at lists.freedesktop.org>
Signed-off-by: Anuj Phogat <anuj.phogat at gmail.com>
---
 src/glsl/ast_array_index.cpp | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/glsl/ast_array_index.cpp b/src/glsl/ast_array_index.cpp
index 299ec91..b23bb69 100644
--- a/src/glsl/ast_array_index.cpp
+++ b/src/glsl/ast_array_index.cpp
@@ -156,23 +156,23 @@ _mesa_ast_array_index_to_hir(void *mem_ctx,
 	    bound = array->type->vector_elements;
 	 }
       } else {
+	 type_name = "array";
 	 /* glsl_type::array_size() returns -1 for non-array types.  This means
 	  * that we don't need to verify that the type is an array before
 	  * doing the bounds checking.
 	  */
 	 if ((array->type->array_size() > 0)
 	     && (array->type->array_size() <= idx)) {
-	    type_name = "array";
 	    bound = array->type->array_size();
 	 }
       }
 
       if (bound > 0) {
-	 _mesa_glsl_error(& loc, state, "%s index must be < %u",
-			  type_name, bound);
+	 _mesa_glsl_warning(& loc, state, "%s index must be < %u",
+		            type_name, bound);
       } else if (idx < 0) {
-	 _mesa_glsl_error(& loc, state, "%s index must be >= 0",
-			  type_name);
+	 _mesa_glsl_warning(& loc, state, "%s index must be >= 0",
+		            type_name);
       }
 
       if (array->type->is_array())
-- 
1.9.3



More information about the mesa-stable mailing list