public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* debug/8354: Incorrect DWARF emitted for const + array + typedef
@ 2002-10-25  8:36 jcownie
  0 siblings, 0 replies; only message in thread
From: jcownie @ 2002-10-25  8:36 UTC (permalink / raw)
  To: gcc-gnats; +Cc: chrisg, nikolay


>Number:         8354
>Category:       debug
>Synopsis:       Incorrect DWARF emitted for const + array + typedef
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Oct 25 08:36:08 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     James Cownie
>Release:        3.2
>Organization:
Etnus LLC
>Environment:
System: Linux pc4 2.4.18 #1 Tue Apr 2 10:17:01 BST 2002 i686 unknown
Architecture: i686
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: /home1/GNU/gcc-3.2/configure 
>Description:
Gcc emits dwarf which has the const qualifier replicated in this test
>How-To-Repeat:
------------------ horrible.c ----------------
typedef int twenty_ints[20];

twenty_ints const const_twenty_array;
twenty_ints twenty_twenty_array[20];

twenty_ints const const_twenty_twenty_array[20];

int main (int argc, char ** argv)
{
  int i = const_twenty_twenty_array[1][1];
}
----------------------------------------------

% gcc -g -o horrible horrible.c
% readelf -wi horrible
The section .debug_info contains:

  Compilation Unit @ 0:
   Length:        291
   Version:       2
   Abbrev Offset: 0
   Pointer Size:  4
 <0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
     DW_AT_stmt_list   : 0	
     DW_AT_high_pc     : 0x804839a 134513562	
     DW_AT_low_pc      : 0x8048380 134513536	
     DW_AT_name        : (indirect string, offset: 0x39): horrible.c	
     DW_AT_comp_dir    : (indirect string, offset: 0x1e): /home1/jim/tmp	
     DW_AT_producer    : (indirect string, offset: 0x0): GNU C 3.2	
     DW_AT_language    : 1	(ANSI C)
 <1><25>: Abbrev Number: 2 (DW_TAG_subprogram)
     DW_AT_sibling     : <69>	
     DW_AT_external    : 1	
     DW_AT_name        : (indirect string, offset: 0x14): main	
     DW_AT_decl_file   : 1	
     DW_AT_decl_line   : 9	
     DW_AT_prototyped  : 1	
     DW_AT_type        : <69>	
     DW_AT_low_pc      : 0x8048380 134513536	
     DW_AT_high_pc     : 0x804839a 134513562	
     DW_AT_frame_base  : 1 byte block: 55 	(DW_OP_reg5; )
 <2><40>: Abbrev Number: 3 (DW_TAG_formal_parameter)
     DW_AT_name        : (indirect string, offset: 0xa): argc	
     DW_AT_decl_file   : 1	
     DW_AT_decl_line   : 8	
     DW_AT_type        : <69>	
     DW_AT_location    : 2 byte block: 91 8 	(DW_OP_fbreg: 8; )
 <2><4e>: Abbrev Number: 3 (DW_TAG_formal_parameter)
     DW_AT_name        : (indirect string, offset: 0xf): argv	
     DW_AT_decl_file   : 1	
     DW_AT_decl_line   : 8	
     DW_AT_type        : <70>	
     DW_AT_location    : 2 byte block: 91 c 	(DW_OP_fbreg: 12; )
 <2><5c>: Abbrev Number: 4 (DW_TAG_variable)
     DW_AT_name        : i	
     DW_AT_decl_file   : 1	
     DW_AT_decl_line   : 10	
     DW_AT_type        : <69>	
     DW_AT_location    : 2 byte block: 91 7c 	(DW_OP_fbreg: -4; )
 <1><69>: Abbrev Number: 5 (DW_TAG_base_type)
     DW_AT_name        : int	
     DW_AT_byte_size   : 4	
     DW_AT_encoding    : 5	(signed)
 <1><70>: Abbrev Number: 6 (DW_TAG_pointer_type)
     DW_AT_byte_size   : 4	
     DW_AT_type        : <76>	
 <1><76>: Abbrev Number: 6 (DW_TAG_pointer_type)
     DW_AT_byte_size   : 4	
     DW_AT_type        : <7c>	
 <1><7c>: Abbrev Number: 7 (DW_TAG_base_type)
     DW_AT_name        : (indirect string, offset: 0x19): char	
     DW_AT_byte_size   : 1	
     DW_AT_encoding    : 6	(signed char)
 <1><83>: Abbrev Number: 8 (DW_TAG_typedef)
     DW_AT_name        : (indirect string, offset: 0x2d): twenty_ints	
     DW_AT_decl_file   : 1	
     DW_AT_decl_line   : 1	
     DW_AT_type        : <8e>	
 <1><8e>: Abbrev Number: 9 (DW_TAG_array_type)
     DW_AT_sibling     : <9e>	
     DW_AT_type        : <69>	
 <2><97>: Abbrev Number: 10 (DW_TAG_subrange_type)
     DW_AT_type        : <9e>	
     DW_AT_upper_bound : 19	
 <1><9e>: Abbrev Number: 7 (DW_TAG_base_type)
     DW_AT_name        : (indirect string, offset: 0x44): unsigned int	
     DW_AT_byte_size   : 4	
     DW_AT_encoding    : 7	(unsigned)
 <1><a5>: Abbrev Number: 9 (DW_TAG_array_type)
     DW_AT_sibling     : <b5>	
     DW_AT_type        : <b5>	
 <2><ae>: Abbrev Number: 10 (DW_TAG_subrange_type)
     DW_AT_type        : <9e>	
     DW_AT_upper_bound : 19	
 <1><b5>: Abbrev Number: 11 (DW_TAG_const_type)
     DW_AT_type        : <69>	
 <1><ba>: Abbrev Number: 12 (DW_TAG_variable)
     DW_AT_name        : (indirect string, offset: 0x6b): const_twenty_array	
     DW_AT_decl_file   : 1	
     DW_AT_decl_line   : 3	
     DW_AT_type        : <cc>	
     DW_AT_external    : 1	
     DW_AT_location    : 5 byte block: 3 20 95 4 8 	(DW_OP_addr: 8049520; )
 <1><cc>: Abbrev Number: 11 (DW_TAG_const_type)
     DW_AT_type        : <a5>	
 <1><d1>: Abbrev Number: 9 (DW_TAG_array_type)
     DW_AT_sibling     : <e7>	
     DW_AT_type        : <69>	
 <2><da>: Abbrev Number: 10 (DW_TAG_subrange_type)
     DW_AT_type        : <9e>	
     DW_AT_upper_bound : 19	
 <2><e0>: Abbrev Number: 10 (DW_TAG_subrange_type)
     DW_AT_type        : <9e>	
     DW_AT_upper_bound : 19	
 <1><e7>: Abbrev Number: 12 (DW_TAG_variable)
     DW_AT_name        : (indirect string, offset: 0x57): twenty_twenty_array	
     DW_AT_decl_file   : 1	
     DW_AT_decl_line   : 4	
     DW_AT_type        : <d1>	
     DW_AT_external    : 1	
     DW_AT_location    : 5 byte block: 3 c0 9b 4 8 	(DW_OP_addr: 8049bc0; )
 <1><f9>: Abbrev Number: 9 (DW_TAG_array_type)
     DW_AT_sibling     : <10f>	
     DW_AT_type        : <b5>	
 <2><102>: Abbrev Number: 10 (DW_TAG_subrange_type)
     DW_AT_type        : <9e>	
     DW_AT_upper_bound : 19	
 <2><108>: Abbrev Number: 10 (DW_TAG_subrange_type)
     DW_AT_type        : <9e>	
     DW_AT_upper_bound : 19	
 <1><10f>: Abbrev Number: 12 (DW_TAG_variable)
     DW_AT_name        : (indirect string, offset: 0x51): const_twenty_twenty_array	
     DW_AT_decl_file   : 1	
     DW_AT_decl_line   : 6	
     DW_AT_type        : <121>	
     DW_AT_external    : 1	
     DW_AT_location    : 5 byte block: 3 80 95 4 8 	(DW_OP_addr: 8049580; )
 <1><121>: Abbrev Number: 11 (DW_TAG_const_type)
     DW_AT_type        : <f9>	

% 

Observe that the type of const_twenty_twenty_array is
 <121> which is Const type <f9>
 <f9>  is an array of type <b5>
 <b5>  is const type <69>

so the type is described with two const qualifiers, which is
wrong, there is only one const qualifier in the source and there
should only be one in the DWARF.

>Fix:
Kill one of the const qualifiers. 
>Release-Note:
>Audit-Trail:
>Unformatted:
 >code.
 


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-10-25 15:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-25  8:36 debug/8354: Incorrect DWARF emitted for const + array + typedef jcownie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).