This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Re: Funky code in gnuv2_virtual_fn_field
- To: Jim Blandy <jimb at zwingli dot cygnus dot com>
- Subject: Re: Funky code in gnuv2_virtual_fn_field
- From: Daniel Berlin <dan at cgsoftware dot com>
- Date: 21 May 2001 21:00:44 -0400
- Cc: Daniel Berlin <dan at cgsoftware dot com>, gdb at sources dot redhat dot com
- References: <20010520160159.3484E5E9DB@zwingli.cygnus.com>
Jim Blandy <jimb@zwingli.cygnus.com> writes:
> I'm looking at lines 112--118 in gnu-v2-abi.c:
>
> if (TYPE_TARGET_TYPE (context) != type1)
> {
> value_ptr tmp = value_cast (context, value_addr (arg1));
> VALUE_POINTED_TO_OFFSET (tmp) = 0;
> arg1 = value_ind (tmp);
> type1 = check_typedef (VALUE_TYPE (arg1));
> }
>
> This looks fishy to me. If we smash the POINTED_TO_OFFSET without
> smashing the ENCLOSING_TYPE in a corresponding manner, and then we
> indirect through that pointer, don't we get a value whose
> ENCLOSING_TYPE is set, but whose address points to the embedded
> object, and not the enclosing object?
Yup.
However, although it's not documented anywhere, value_cast
approriately smashes the enclosing type.
In fact, it should also smash the pointed_to_offset when necessary,
making this explicit smashing pointless, and possibly incorrect.
Though now that i look at it some more, I'm not positive value_cast is
doing the right thing in all cases. It's pretty hard to follow,
however, and I just got home from a 7 hour car ride (graduated
yesterday, and moved out), so i may just be loopy.
IMHO, in any case, we shouldn't be needing to set the
pointed_to_offset here. If we have to, value_cast is doing something
wrong, or not enough of the right thing.
This is because all we are trying to do is a simple cast, which is what
value_cast is supposed to do for us. If we have to start mucking
around with it's results to get a correct value, then it's not doing
it's job right, or completely.
--
"I hooked up my accelerator pedal in my car to my brake lights.
I hit the gas, people behind me stop, and I'm gone.
"-Steven Wright