diff --git a/Parser/Gmsh.tab.cpp b/Parser/Gmsh.tab.cpp
index b9b9d48e1c19c1efae5003611ad83bc81d053e3e..684bb245be9249c14721a94a51d9337d1652a167 100644
--- a/Parser/Gmsh.tab.cpp
+++ b/Parser/Gmsh.tab.cpp
@@ -14155,12 +14155,13 @@ double treat_Struct_FullName_Float
       }
       else if (type_var == 2) {
         gmsh_yysymbol &s(gmsh_yysymbols[c2]);
-        if((int)s.value.size() < index + 1){
+        if(index < 0 || (int)s.value.size() < index + 1){
           out = val_default;
           if (type_treat == 0) yymsg(0, "Uninitialized variable '%s[%d]'", c2, index);
         }
-        else
+        else{
           out = s.value[index];
+        }
       }
       else {
         out = val_default;
diff --git a/Parser/Gmsh.y b/Parser/Gmsh.y
index f733ad39e9a82a6640c034be1e7e041da9abd479..1ac1690f83f91b62529a794e16fe729cee987a1f 100644
--- a/Parser/Gmsh.y
+++ b/Parser/Gmsh.y
@@ -6702,12 +6702,13 @@ double treat_Struct_FullName_Float
       }
       else if (type_var == 2) {
         gmsh_yysymbol &s(gmsh_yysymbols[c2]);
-        if((int)s.value.size() < index + 1){
+        if(index < 0 || (int)s.value.size() < index + 1){
           out = val_default;
           if (type_treat == 0) yymsg(0, "Uninitialized variable '%s[%d]'", c2, index);
         }
-        else
+        else{
           out = s.value[index];
+        }
       }
       else {
         out = val_default;