https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71668
Bug ID: 71668
Summary: certain bitfields get negative DW_AT_bit_offset
Product: gcc
Version: 5.3.0
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: debug
Assignee: unassigned at gcc dot gnu.org
Reporter: richlowe at richlowe dot net
Target Milestone: ---
Created attachment 38770
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38770&action=edit
test case source
The DWARF for certain structures, at least when using -gdwarf-2, seems to emit
with a signed, negative, bitoffset. I'm not sure whether that's valid, but
it's causing some of our tools to choke and since it seems to happen in such a
narrow range of circumstances it seems to be, at the least, suspicious. The
DWARF standards seem to have little to say on the matter.
It appears to happen when a bitfield structure is between 33 and 39 bits in
size, and at no other time I've been able to determine (a large source tree
contains only a single instance of the problem, from which this test case was
reduced). Perhaps something is off-by-one on the number of bytes somewhere?
My apologies if this behaviour is correct.
I'm attaching a test file, the following diff shows the dwarfdump between a
good and bad sized version of the bitfield:
--- good.dwarf 2016-06-26 18:40:52.582216186 +0100
+++ bad.dwarf 2016-06-26 18:41:09.862679856 +0100
@@ -23,8 +23,8 @@
DW_AT_decl_line 0x00000004
DW_AT_type <0x00000050>
DW_AT_byte_size 0x00000004
- DW_AT_bit_size 0x00000008
- DW_AT_bit_offset 0x00000018
+ DW_AT_bit_size 0x00000007
+ DW_AT_bit_offset 0x00000019
DW_AT_data_member_location DW_OP_plus_uconst 0
< 2><0x0000003e> DW_TAG_member
DW_AT_name "csts_cfs"
@@ -33,8 +33,8 @@
DW_AT_type <0x00000050>
DW_AT_byte_size 0x00000004
DW_AT_bit_size 0x00000020
- DW_AT_bit_offset 0x00000000
- DW_AT_data_member_location DW_OP_plus_uconst 1
+ DW_AT_bit_offset 0xfffffffffffffff9
+ DW_AT_data_member_location DW_OP_plus_uconst 0
< 1><0x00000050> DW_TAG_base_type
DW_AT_byte_size 0x00000004
DW_AT_encoding DW_ATE_unsigned