Issue 250501.1: Dynamic DW_AT_data_bit_offset

Author: Tom Tromey
Champion: Simon Marchi
Date submitted: 2025-05-01
Date revised:
Date closed: 2025-08-15
Type: Enhancement
Status: Rejected
DWARF version: 6

Consider the following Ada program:

procedure Exam is
   type Small is range -7 .. -4;
   for Small'Size use 2;

   type Packed_Array is array (Integer range <>) of Small;
   pragma pack (Packed_Array);

   subtype Range_Int is Natural range 0 .. 7;

   type Some_Packed_Record (Discr : Range_Int := 3) is record
      Array_Field : Packed_Array (1 .. Discr);
      Field       : Small;
      case Discr is
     when 3 =>
        Another_Field : Small;

     when others =>
        null;
      end case;
   end record;
   pragma Pack (Some_Packed_Record);
   pragma No_Component_Reordering (Some_Packed_Record);

   SPR : Some_Packed_Record :=
     (Discr         => 3,
      Field         => -4,
      Another_Field => -6,
      Array_Field   => (-5, -6, -7));

begin
   null;
end Exam;

The offset to the field "Another_Field" is non-constaint and non-byte-aligned. There is no good way to represent this with DWARF 5:

Proposal

Allow DW_AT_data_bit_offset to have a value of the class "exprval".

Notes


2025-08-15: Rejected. The locations on the stack proposal, 230524.1, will address this issue by allowing a DW_AT_bit_offset operator to add the bit offset to an arbitrary location. A new proposal, 250815.1, to clarify the ways of describing a data member's location, has been proposed.