diff --git a/gdb/eval.c b/gdb/eval.c
index 85cf071..2824854 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -51,7 +51,8 @@ extern int overload_resolution;
 
 /* Prototypes for local functions.  */
 
-static struct value *evaluate_subexp_for_sizeof (struct expression *, int *);
+static struct value *evaluate_subexp_for_sizeof (struct expression *, int *,
+						 enum noside);
 
 static struct value *evaluate_subexp_for_address (struct expression *,
 						  int *, enum noside);
@@ -2563,7 +2564,7 @@ evaluate_subexp_standard (struct type *expect_type,
 	  evaluate_subexp (NULL_TYPE, exp, pos, EVAL_SKIP);
 	  goto nosideret;
 	}
-      return evaluate_subexp_for_sizeof (exp, pos);
+      return evaluate_subexp_for_sizeof (exp, pos, noside);
 
     case UNOP_CAST:
       (*pos) += 2;
@@ -2998,10 +2999,13 @@ evaluate_subexp_with_coercion (struct expression *exp,
 
 /* Evaluate a subexpression of EXP, at index *POS,
    and return a value for the size of that subexpression.
-   Advance *POS over the subexpression.  */
+   Advance *POS over the subexpression. If NOSIDE is EVAL_NORMAL
+   we allow side-effects on the operand if its type is a variable
+   length array.   */
 
 static struct value *
-evaluate_subexp_for_sizeof (struct expression *exp, int *pos)
+evaluate_subexp_for_sizeof (struct expression *exp, int *pos,
+			    enum noside noside)
 {
   /* FIXME: This should be size_t.  */
   struct type *size_type = builtin_type (exp->gdbarch)->builtin_int;
@@ -3055,6 +3059,37 @@ evaluate_subexp_for_sizeof (struct expression *exp, int *pos)
       return
 	value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type));
 
+      /* Deal with the special case if NOSIDE is EVAL_NORMAL and the resulting
+	 type of the subscript is a variable length array type. In this case we
+	 must re-evaluate the right hand side of the subcription to allow
+	 side-effects. */
+    case BINOP_SUBSCRIPT:
+      if (noside == EVAL_NORMAL)
+	{
+	  int pc = (*pos) + 1;
+
+	  val = evaluate_subexp (NULL_TYPE, exp, &pc, EVAL_AVOID_SIDE_EFFECTS);
+	  type = check_typedef (value_type (val));
+	  if (TYPE_CODE (type) == TYPE_CODE_ARRAY)
+	    {
+	      type = check_typedef (TYPE_TARGET_TYPE (type));
+	      if (TYPE_CODE (type) == TYPE_CODE_ARRAY)
+		{
+		  type = TYPE_INDEX_TYPE (type);
+		  /* Only re-evaluate the right hand side if the resulting type
+		     is a variable length type.  */
+		  if (TYPE_RANGE_DATA (type)->flag_bound_evaluated)
+		    {
+		      val = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_NORMAL);
+		      return value_from_longest
+			(size_type, (LONGEST)TYPE_LENGTH (value_type (val)));
+		    }
+		}
+	    }
+	}
+
+      /* Fall through.  */
+
     default:
       val = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
       return value_from_longest (size_type,
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 61a5b3d..e4c6c4c 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1647,6 +1647,7 @@ resolve_dynamic_bounds (struct type *type, CORE_ADDR addr)
     = create_range_type (NULL,
 			 TYPE_TARGET_TYPE (range_type),
 			 &low_bound, &high_bound);
+  TYPE_RANGE_DATA (range_type)->flag_bound_evaluated = 1;
   elt_type = create_array_type (copy_type (type),
 				elt_type,
 				range_type);
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index d0757e5..265bdc2 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -626,6 +626,11 @@ struct main_type
 	 subrange. This affects how the final hight bound is computed.  */
 
       int flag_upper_bound_is_count : 1;
+
+      /* True if LOW or/and HIGH are resolved into a static bound from
+	 a dynamic one.  */
+
+      int flag_bound_evaluated : 1;
     } *bounds;
 
   } flds_bnds;
diff --git a/gdb/testsuite/gdb.base/vla-sideeffect.c b/gdb/testsuite/gdb.base/vla-sideeffect.c
new file mode 100644
index 0000000..6e42a64
--- /dev/null
+++ b/gdb/testsuite/gdb.base/vla-sideeffect.c
@@ -0,0 +1,42 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2014 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <stddef.h>
+#define SIZE 10
+
+int
+main (void)
+{
+  int n = SIZE;
+  int i = 0;
+  int j = 0;
+  int vla2[SIZE][n];
+  int vla1[n];
+
+  for (i = 0; i < n; i++)
+    vla1[i] = (i * 2) + n;
+
+  for (i = 0; i < SIZE; i++)
+    for (j = 0; j < n; j++)
+      vla2[i][j] = (i + j) + n;
+
+
+  i = 0;
+  j = 0;
+
+  return 0;           /* vla-filled */
+}
diff --git a/gdb/testsuite/gdb.base/vla-sideeffect.exp b/gdb/testsuite/gdb.base/vla-sideeffect.exp
new file mode 100644
index 0000000..f6717f0
--- /dev/null
+++ b/gdb/testsuite/gdb.base/vla-sideeffect.exp
@@ -0,0 +1,89 @@
+# Copyright 2014 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Tests side-effects of sizeof evaluation.
+# Based on gcc/testsuite/gcc.dg/vla-4.c; vla-15.c
+
+standard_testfile
+
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
+    return -1
+}
+
+if ![runto_main] {
+    return -1
+}
+
+gdb_breakpoint [gdb_get_line_number "vla-filled"]
+gdb_continue_to_breakpoint "vla-filled"
+
+# Check side effects for sizeof argument.
+set sizeof_int [get_sizeof "int" 4]
+set sizeof_vla [ expr "10" * "$sizeof_int" ]
+
+gdb_test "print sizeof (vla1\[i++\])" "= ${sizeof_int}" \
+         "print sizeof (vla1\[i++\])"
+gdb_test "print i" " = 0" \
+         "print i - sizeof no side effects"
+
+gdb_test "print sizeof (++vla1\[0\])" " = ${sizeof_int}" \
+         "print sizeof (++vla1\[0\])"
+gdb_test "print vla1\[0\]" " = 10" \
+         "print vla1\[0\] - sizeof no side effects"
+
+gdb_test "ptype ++vla1\[0\]" "type = int" "ptype ++vla1\[0\]"
+gdb_test "print vla1\[0\]" " = 10" \
+         "print vla1\[0\] - ptype no side effects"
+
+gdb_test "whatis ++vla1\[0\]" "type = int" "whatis ++vla1\[0\]"
+gdb_test "print vla1\[0\]" " = 10" \
+         "print vla1\[0\] - whatis no side effects"
+
+
+gdb_test "print sizeof (vla2\[i++\])" " = ${sizeof_vla}" \
+         "print sizeof (vla2\[i++\])"
+gdb_test "print i" " = 1" \
+         "print i - sizeof with side effects (1)"
+
+gdb_test "print sizeof (vla2\[i++ + sizeof(j++)\])" " = ${sizeof_vla}" \
+         "print sizeof (vla2\[i++ + sizeof(j++)\])"
+gdb_test "print i" " = 2" \
+         "print i - sizeof with side effects (2)"
+gdb_test "print j" " = 0" \
+         "print j - sizeof with no side effects"
+
+gdb_test "ptype vla2\[i++\]" "type = int \\\[10\\\]" \
+         "ptype vla2\[i++\]"
+gdb_test "print i" " = 2" \
+         "print i - ptype with side effects (1)"
+
+gdb_test "ptype vla2\[i++ + sizeof(j++)\]" "type = int \\\[10\\\]" \
+         "ptype vla2\[i++ + sizeof(j++)\]"
+gdb_test "print i" " = 2" \
+         "print i - ptype with side effects (2)"
+gdb_test "print j" " = 0" \
+         "print j - ptype with no side effects"
+
+gdb_test "whatis vla2\[i++\]" "type = int \\\[10\\\]" \
+         "whatis vla2\[i++\]"
+gdb_test "print i" " = 2" \
+         "print i - whatis with side effects (1)"
+
+gdb_test "whatis vla2\[i++ + sizeof(j++)\]" "type = int \\\[10\\\]" \
+         "whatis vla2\[i++ + sizeof(j++)\]"
+gdb_test "print i" " = 2" \
+         "print i - whatis with side effects (2)"
+gdb_test "print j" " = 0" \
+         "print j - whatis with no side effects"
