Re: how to support C type qualifiers applied to arrays?

Jim Blandy
2006-11-27T23:30:40Z

Daniel Jacobowitz <drow@false.org> writes:
> On Mon, Nov 27, 2006 at 02:42:12PM -0800, Gary Funck wrote:
>> Q: Is GCC generating an inaccurate DWARF 2 representation
>> to describe a qualified array type, or is GDB not
>> interpreting the DWARF 2 information correctly?
>
> I will defer to experts on this but I believe GCC is incorrect.

I think GCC is wrong, too. The DWARF is unambiguous, and it's
attaching the qualifiers to the wrong part of the type tree, just as
Daniel says.

> My first recommendation would be to have make_cv_type create a new
> array type, with the qualified element type. However, doing this
> without being excessively wasteful might require care - you couldn't
> reuse main_type since the qualified array could not share main_type.
> But the waste is acceptably small.

If this were a less obscure feature, then I could see GDB deliberately
misreading the DWARF to accomodate GCC. But in this case, it doesn't
seem like a show-stopper; wouldn't it be better to just report the GCC
bug and let GDB continue to interpret DWARF as written? These kludges
come back to haunt us. I gather Gary is working with a modified GCC
anyway, so it shouldn't be hard for him to fix his compiler. (If
that's not so, Gary, please set me straight.)