On Jul 27, 2024, David Blaikie <dblai...@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 -- Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/ Free Software Activist GNU Toolchain Engineer Disinformation flourishes because many people care deeply about injustice but very few check the facts. Think Assange & Stallman. The empires strike back -- Dwarf-discuss mailing list Dwarf-discuss@lists.dwarfstd.org https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss