🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gdb.bug
Article #10122

GDB does not understand variable arrays.

#10122
From: ian
Date: Sun, 27 May 1990 12:05
47 lines
1828 bytes
The following program was compiled with gcc 1.37.1 producing dbx style
debugging information.

void foo (int n, int [n][n]);

main()
{
  int x[10][10];
  int i, j;
  for (i = 0; i < 10; i++)
    for (j = 0; j < 10; j++)
      x[i][j] = i * 10 + j;
  foo(10, x);
}

void foo (int n, int x[n][n])
{
  printf("%d\n", x[1][1]);
}


The following is a transcript of a GDB session. It does not report the
correct type for the array argument (it should be int (*)[10] or
int (*)[n]) and it consequently prints out the wrong value when asked
to print x[1][1].

Current directory is /usr/u/ian/tmp/
GDB 3.5, Copyright (C) 1989 Free Software Foundation, Inc.
There is ABSOLUTELY NO WARRANTY for GDB; type "info warranty" for details.
GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "info copying" to see the conditions.
Reading symbol data from /usr/u/ian/tmp/array...done.
Type "help" for a list of commands.
(gdb) b foo
Reading in symbols for array.c...done.
Breakpoint 1 at 0x1fa: file array.c, line 14.
(gdb) r
Starting program: /usr/u/ian/tmp/array 

Bpt 1, foo (n=10, x=(int (*)[1]) 0xfffae8) (array.c line 15)
(gdb) p x[1][1]
$1 = 2
(gdb) next
11


Ian Dall
Technical Details
Message-ID: <9005271633.2256@munnari.oz.au>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!sibyl.eleceng.ua.oz.au!ian

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f5053,313b54817bd98e83,start
X-Google-Attributes: gidf5053,public
X-Google-ArrivalTime: 1990-05-27 10:25:50 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!sibyl.eleceng.ua.oz.au!ian
From: ian@sibyl.eleceng.ua.oz.au
Newsgroups: gnu.gdb.bug
Subject: GDB does not understand variable arrays.
Message-ID: <9005271633.2256@munnari.oz.au>
Date: 27 May 90 12:05:02 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 47
Posted: Sun May 27 13:05:02 1990