[Dwarf-discuss] Proposal/clarification: "inherited" subrange bounds

David Blaikie dblaikie@gmail.com
Mon Jul 29 17:45:29 GMT 2024


On Sat, Jul 27, 2024 at 10:50 PM Alexandre Oliva <oliva@gnu.org> wrote:

> On Jul 27, 2024, David Blaikie <dblaikie@gmail.com> wrote:
>
> > If I'm following correctly, Alexandre - you're suggesting a situation
> where
> > an instance of a type, when it appears within a packed struct, may become
> > smaller than it would otherwise be?
>
> It's a philosophical question whether it's smaller in a packed struct or
> larger otherwise, a bit like whether the Tardis is bigger in the inside
> or smaller on the outside ;-D, but fact is that both kinds of uses of
> the same type can be common in a unit, so it would be desirable to
> represent those types with their sizes once, rather than e.g. override
> it at every variable or field.
>
> Right now, we represent two distinct, unrelated types to that end.  ISTM
> that it would be better to be able to relate them, using one as the base
> type for the other.  Sharing the bounds would be desirable, but it's not
> clear that omitting them in the derived type would achieve the desired
> result.  That's what this thread is about.
>
> > (usually in C that's not the case -
>
> *nod*, the issue at hand came from Ada.
>
> > If you have a language where "packing" a member might cause it to become
> > smaller, not just cause the leading/trailing padding to be omitted -
> > perhaps that'd be better modelled, not with a new/distinct type, but with
> > the same mechanism as is used for bitfields in C? ie: using bit_size and
> > data_bit_offset?
>
> The situation is not very different, but in Ada one can specify the
> target size (in bits) for the type (which may require biased
> representations, but that's besides the point).  Despite the specified
> size, standalone variables and members of unpacked types use full
> storage units, unless packing is requested.  See
> e.g.
> https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/testsuite/gnat.dg/bias1.adb


I see, so do I understand correctly that you'd prefer not to use the
bitfield style representation, because it'd be repetitious? (having to put
it on every member of that type when packed?) Or are there other problems
with it?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.dwarfstd.org/pipermail/dwarf-discuss/attachments/20240729/052f41c3/attachment-0001.htm>


More information about the Dwarf-discuss mailing list