public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c/6885: Incorrect DWARF3 emitted for C VLA constructs
@ 2002-05-31  5:16 jcownie
  0 siblings, 0 replies; only message in thread
From: jcownie @ 2002-05-31  5:16 UTC (permalink / raw)
  To: gcc-gnats


>Number:         6885
>Category:       c
>Synopsis:       Incorrect DWARF2 emitted for C VLA constructs
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri May 31 04:56:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     James Cownie
>Release:        3.1
>Organization:
jcownie@etnus.com
>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.1/configure 
>Description:
The DWARF3 debug information emitted for C variable length array
objects is incorrect (and incomplete).

I am aware that the compiler's support for these constructs is listed
as "broken", however this code, at least, appears to work, it's just
that the debug information emitted is incomplete/incorrect.

Consider code like this

//
// A simple test for variable size arrays
// (Use // comments just for amusement).
//
#include <stdio.h>

int foo(int x)
{
  return x;
}

int takes_adjustable (int dim1, int dim2, int adjustable[dim1][foo(dim2)])
{
  int sum = 0;
  int i;
  for (i=0; i<dim1; i++)
    {
      int j;
      for (j=0; j<dim2; j++)
	sum += adjustable[i][j];
    }

  return sum;
}

int local_adjustable (int dim)
{
  int la [dim];
  int i;

  for (i=0; i<dim; i++)
    la[i] = i;

  return dim;
}

int main (int argc, char ** argv)
{
  int la [argc][argc*argc];
  int i;

  for (i=0; i<argc; i++)
    {
      int j;
      for (j=0; j<argc*argc; j++)
	la[i][j] = i*j;
    }

  printf ("Sum is %d\n", takes_adjustable (argc, argc*argc, la));
  local_adjustable (20);
}

If we look at the DWARF emitted for the argument "adjustable" in
takes_adjustable we see (relevant chunks extracted from readelf -wi) :-

 <2><d2a>: Abbrev Number: 26 (DW_TAG_formal_parameter)
     DW_AT_name        : adjustable	
     DW_AT_decl_file   : 1	
     DW_AT_decl_line   : 12	
     DW_AT_type        : <d88>	
     DW_AT_location    : 2 byte block: 91 10 	(DW_OP_fbreg: 16; )

 <1><d88>: Abbrev Number: 11 (DW_TAG_pointer_type)
     DW_AT_byte_size   : 4	
     DW_AT_type        : <d70>	

** It's a pointer to an object of type <d70>

 <1><d70>: Abbrev Number: 4 (DW_TAG_array_type)
     DW_AT_sibling     : <d83>	
     DW_AT_type        : <97>	
 <2><d79>: Abbrev Number: 30 (DW_TAG_subrange_type)
     DW_AT_type        : <90>	
     DW_AT_upper_bound : <d21>	

** <d70> is an array of type <97> with an upperbound of variable <d21>

 <1><97>: Abbrev Number: 7 (DW_TAG_base_type)
     DW_AT_name        : int	
     DW_AT_byte_size   : 4	
     DW_AT_encoding    : 5	(signed)
** <97> is an integer

 <2><d21>: Abbrev Number: 27 (DW_TAG_variable)
     DW_AT_artificial  : 1	
     DW_AT_type        : <d83>	
     DW_AT_location    : 2 byte block: 91 70 	(DW_OP_fbreg: -16; )

** <d21> is some store location of type <d83>

 <1><d83>: Abbrev Number: 19 (DW_TAG_const_type)
     DW_AT_type        : <97>	

** <d83> is a const int.

So, we're completely missing the _second_ dimension of this object,
it's been declared as a vector of int, rather than either a vector of
vector of int, or 2D array of int.

>How-To-Repeat:
As above.

>Fix:
Unknown
>Release-Note:
>Audit-Trail:
>Unformatted:


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

only message in thread, other threads:[~2002-05-31 11:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-31  5:16 c/6885: Incorrect DWARF3 emitted for C VLA constructs 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).