[Bug debug/16788] New: [3.3 regression] Incorrect DWARF-2 offset for long long struct member
kmassey at incipient dot com
gcc-bugzilla@gcc.gnu.org
Tue Jul 27 19:37:00 GMT 2004
gcc 3.3.1 produces incorrect DWARF-2 offset for a long long struct member.
Reproduced in gcc 3.3.1 and 3.3.4.
Not reproducible in gcc 3.2.2.
To reproduce:
------- bug.c --------------------------------
int
main()
{
struct foo {
char c;
long long l;
};
struct foo f;
int i;
i = (char *)&f.l - (char *)&f;
return 0;
}
----------------------------------------------
$ gcc -v -gdwarf-2 bug.c
Reading specs from /usr/lib/gcc-lib/i686-redhat-linux/3.3.1/specs
Configured with: ../configure --prefix=/usr --enable-shared --enable-threads --
disable-nls i686-redhat-linux
Thread model: posix
gcc version 3.3.1
/usr/lib/gcc-lib/i686-redhat-linux/3.3.1/cc1 -quiet -v -D__GNUC__=3 -
D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=1 bug.c -quiet -dumpbase bug.c -auxbase
bug -gdwarf-2 -version -o /tmp/ccJzm0tb.s
GNU C version 3.3.1 (i686-redhat-linux)
compiled by GNU C version 3.3.1.
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=64222
ignoring nonexistent directory "/usr/i686-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/lib/gcc-lib/i686-redhat-linux/3.3.1/include
/usr/include
End of search list.
as -V -Qy -o /tmp/ccUw4qEb.o /tmp/ccJzm0tb.s
GNU assembler version 2.13.90.0.2 (i386-redhat-linux) using BFD version
2.13.90.0.2 20020802
/usr/lib/gcc-lib/i686-redhat-linux/3.3.1/collect2 --eh-frame-hdr -m elf_i386 -
dynamic-linker /lib/ld-linux.so.2 /usr/lib/gcc-lib/i686-redhat-
linux/3.3.1/../../../crt1.o /usr/lib/gcc-lib/i686-redhat-
linux/3.3.1/../../../crti.o /usr/lib/gcc-lib/i686-redhat-
linux/3.3.1/crtbegin.o -L/usr/lib/gcc-lib/i686-redhat-linux/3.3.1 -
L/usr/lib/gcc-lib/i686-redhat-linux/3.3.1/../../.. /tmp/ccUw4qEb.o -lgcc -
lgcc_eh -lc -lgcc -lgcc_eh /usr/lib/gcc-lib/i686-redhat-
linux/3.3.1/crtend.o /usr/lib/gcc-lib/i686-redhat-linux/3.3.1/../../../crtn.o
$ readelf -wi a.out
[snip]
<2><c6d>: Abbrev Number: 3 (DW_TAG_structure_type)
DW_AT_sibling : <c92>
DW_AT_name : foo
DW_AT_byte_size : 12
DW_AT_decl_file : 1
DW_AT_decl_line : 4
<3><c79>: Abbrev Number: 4 (DW_TAG_member)
DW_AT_name : c
DW_AT_decl_file : 1
DW_AT_decl_line : 5
DW_AT_type : <cb2>
DW_AT_data_member_location: 2 byte block: 23 0 (DW_OP_plus_uconst: 0; )
<3><c85>: Abbrev Number: 4 (DW_TAG_member)
DW_AT_name : l
DW_AT_decl_file : 1
DW_AT_decl_line : 6
DW_AT_type : <cb9>
DW_AT_data_member_location: 2 byte block: 23 8 (DW_OP_plus_uconst: 8; )
[snip]
----------------------------------------------
Note that the offset of foo.l is 8 instead of the expected 4.
This can be demonstrated under the debugger:
----------------------------------------------
$ gdb ./a.out
GNU gdb Red Hat Linux (5.2.1-4)
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux"...
(gdb) b 14
Breakpoint 1 at 0x8048334: file bug.c, line 14.
(gdb) run
Starting program: /home/kmassey/gcc-bugs/a.out
Breakpoint 1, main () at bug.c:14
14 return 0;
(gdb) p i
$1 = 4
(gdb) p (char *)&f.l - (char *)&f
$2 = 8
----------------------------------------------
By contrast, -gstabs+ works as expected:
----------------------------------------------
$ gcc -gstabs+ bug.c
[kmassey@kmlx1 gcc-bugs]$ gdb ./a.out
GNU gdb Red Hat Linux (5.2.1-4)
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux"...
(gdb) b 14
Breakpoint 1 at 0x8048334: file bug.c, line 14.
(gdb) run
Starting program: /home/kmassey/gcc-bugs/a.out
Breakpoint 1, main () at bug.c:14
14 return 0;
(gdb) p i
$1 = 4
(gdb) p (char *)&f.l - (char *)&f
$2 = 4
----------------------------------------------
--
Summary: [3.3 regression] Incorrect DWARF-2 offset for long long
struct member
Product: gcc
Version: 3.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: debug
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: kmassey at incipient dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16788
More information about the Gcc-bugs
mailing list