This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 05/10] vla: allow side effects for sizeof argument


C99 requires the sizeof operator to be evaluated at runtime to compute
the size of the vla, reflect this behavior in gdb.

1| void foo (size_t n, int vla[n][n]) {
2| }

(gdb) p sizeof(vla[0])

yields N.

2013-10-18  Sanimir Agovic  <sanimir.agovic@intel.com>
            Keven Boell  <keven.boell@intel.com>

	* eval.c (evaluate_subexp_for_sizeof): Allow side effects for
	argument to sizeof.

Change-Id: I945e8a259e850cc0470faa742a0d2191122ef37b
---
 gdb/eval.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/gdb/eval.c b/gdb/eval.c
index ab3cb95..91cc299 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -3055,7 +3055,7 @@ evaluate_subexp_for_sizeof (struct expression *exp, int *pos)
 	value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type));
 
     default:
-      val = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
+      val = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_NORMAL);
       return value_from_longest (size_type,
 				 (LONGEST) TYPE_LENGTH (value_type (val)));
     }
-- 
1.7.0.7


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]