Bug 56740 - duplicat DW_TAG_const_type
Summary: duplicat DW_TAG_const_type
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-debug
Depends on:
Blocks:
 
Reported: 2013-03-26 13:42 UTC by Tom Tromey
Modified: 2021-08-30 03:17 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Tromey 2013-03-26 13:42:04 UTC
I used this source, from PR 55608:

static const char *a = "opq";
static const char b[8] = "rstuv";
static const char *c = b;
static const char *d = b + 3;
static const int e[] = { 1, 2, 3, 4 };
static int f[] = { 5, 6, 7 };
static const int *g = e;
static const int *h = e + 2;
static const int *i = f;
static const int *j = f + 2;

int
main ()
{
  const char *p = "abcd";
  const char *q = "efgh";
  const char r[] = "ijk\0lmn";
  const char *s = r;
  const char *t = b;
  const int *u = e;
  const int *v = e + 2;
  const int *w = f;
  const int *x = f + 2;
  return 0;
}


I compiled this with "gcc -g -O2", using git master gcc from
yesterday.

The DWARF contains some needless duplication:

 <1><fd>: Abbrev Number: 7 (DW_TAG_const_type)
    <fe>   DW_AT_type        : <0xe6>	

 <1><12f>: Abbrev Number: 7 (DW_TAG_const_type)
    <130>   DW_AT_type        : <0xe6>
Comment 1 Mark Wielaard 2014-02-25 11:34:38 UTC
Replicated with gcc (GCC) 4.9.0 20140219 (experimental)

 [    d7]    array_type
             type                 (ref4) [    d0]

 [    ee]    const_type
             type                 (ref4) [    d7]

 [   124]    const_type
             type                 (ref4) [    d7]

DIE ee is referenced from:

 [    66]      variable
               name                 (string) "r"
               decl_file            (data1) 1
               decl_line            (data1) 17
               type                 (ref4) [    ee]
               location             (exprloc)                 [   0] fbreg -96

That is const char r[] = "ijk\0lmn"; in main ().

DIE 124 is referenced from:

 [   111]    variable
             name                 (string) "b"
             decl_file            (data1) 1
             decl_line            (data1) 2
             type                 (ref4) [   124]
             location             (exprloc)               [   0] addr 0x400644 <b>

That is the global static const char b[8] = "rstuv";

Do those 2 really represent the same type?