diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 5f9450981a..ebeb2ef3a5 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2014-04-11 Sanimir Agovic + + * eval.c (evaluate_subexp_for_sizeof) : If the type + passed to sizeof is dynamic evaluate the argument to compute the length. + 2014-04-11 Sanimir Agovic * dwarf2loc.c (dwarf2_locexpr_baton_eval): New function. diff --git a/gdb/eval.c b/gdb/eval.c index 36615e17cd..26454f60a2 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -3040,8 +3040,14 @@ evaluate_subexp_for_sizeof (struct expression *exp, int *pos) return value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type)); case OP_VAR_VALUE: - (*pos) += 4; type = check_typedef (SYMBOL_TYPE (exp->elts[pc + 2].symbol)); + if (is_dynamic_type (type)) + { + val = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_NORMAL); + type = value_type (val); + } + else + (*pos) += 4; return value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type));