This has got to be a bug!

gdb 5.0 configured as "i586-pc-linux-gnu".

For (but with default constructors) 

class base{public: int i;};
class dervied: public base{public: int j;};

base* unknown = new derived();

Using gdb and 'print *(derived*)unknown' gives
incorrect/random values of derived::j.

In print_cmd_1 I believe the call

val = evaluate_expression (expr);

is incorrectly assigning val->enclosing_type. This should be
of type 'derived'
i.e. val->enclosing_type == val->type and not of type 'base'
which loosely speaking is what
it is being assigned to.

What happens is that the data values are transfered out via
ptrace for the size of the base class 'base' but no further
calls are made to ptrace. The values are then printed out
for the entire size of the derived class leading to randon
values of derived::j. Using another gdb, assigning
val->enclosing_type == val->type after the call to
evaluate_expression() works perfectly as data is extracted
for the entire size of 'derived'.

In my code I have to put
{
        derived* known = (derived*)unknown;
}
 
in order to print the values correctly.

Thanks for your time
  
James

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

_______________________________________________
Bug-gdb mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-gdb

Reply via email to