Bug 527430

Summary: DW_AT_const_value duplicated between DW_TAG_variable abstract declaration and instance
Product: [Fedora] Fedora Reporter: Mark Wielaard <mjw>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: rawhideCC: jakub
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-10-08 19:08:46 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Mark Wielaard 2009-10-06 12:07:25 UTC
Description of problem:

DW_AT_const_value is unnecessary duplicated.

Version-Release number of selected component (if applicable):

GNU C 4.4.1 20091001 (Red Hat 4.4.1-18)

How reproducible:

Always

Steps to Reproduce:
1. cat const.c
struct foo
{
  const int i;
  const long j;
};

typedef struct foo fooer;

static int
bar (const int i, const long j)
{
  return i * j;
}

static int
func (int (*f) ())
{
  const fooer baz = { .i = 2, .j = 21 };
  return f(baz.i, baz.j);
}

int
main (int argc, char *argv[], char *envp[])
{
  return func (&bar) - 42;
}

2. gcc -g -O2 -o const const.c

3. readelf --debug-dump=info const

Actual results:

 <2><8b>: Abbrev Number: 10 (DW_TAG_variable)
    <8c>   DW_AT_name        : baz      
    <90>   DW_AT_decl_file   : 1        
    <91>   DW_AT_decl_line   : 18       
    <92>   DW_AT_type        : <0xb9>   
    <96>   DW_AT_const_value : 16 byte block: 2 0 0 0 0 0 0 0 15 0 0 0 0 0 0 0  
[...]
 <4><17c>: Abbrev Number: 21 (DW_TAG_variable)
    <17d>   DW_AT_abstract_origin: <0x8b>       
    <181>   DW_AT_const_value : 16 byte block: 2 0 0 0 0 0 0 0 15 0 0 0 0 0 0 0         

Expected results:

Not having the DW_AT_const_value in the instance when the value is already in the abstract_origin.

Comment 1 Jakub Jelinek 2009-10-08 19:08:46 UTC
Fixed in gcc-4.4.1-20.fc12.