https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78839

--- Comment #10 from Tom O'Connor <toconnor at forcepoint dot com> ---
In regards to GDB, I noticed that when using a macro to get the offset for
these bitfields, with objects built by both GCC 5 and earlier as well as GCC 6,
I always get 0.  For example:

(gdb) macro define offsetof(t, f) &((t *) 0)->f)
(gdb) p offsetof(struct s, type)
$1 = (unsigned int *) 0x0

Historically, prior to GCC 6, this always matched up with DWARF's
DW_AT_data_member_location value for bitfields.  Yes, I see how GCC 6's
combination of data_member_location and bit_offset can be combined to reach the
true location.  Historically, my use case has used the data_member_location
value to get me the offset into say a raw memory image, for where to start
reading data from a field of a structure in memory; I'd do bitfield shifts
after reading from the aligned offset as reported in the DWARF structure.

If using DECL_BIT_FIELD_REPRESENTATIVE as data_member_location is nicer and
doesn't break the Ada use case, I'd be all for that.  But if what's currently
being emitted by GCC 6 is considered "more correct" than what previous versions
had emitted, then I'll have to adjust.  I only noticed the change between 5 and
6 once I started seeing odd results with the same code built by different GCCs.

Reply via email to