🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gdb.bug
Article #8848

print of zero length arrays

#8848
From: Pierre Willard
Date: Fri, 18 Sep 1992 00:52
53 lines
2468 bytes
In gdb-4.5, a print of a zero length array ends up in error with the
following message : "Value not integer or pointer."

I think that, since gcc allows such structures, gdb should not
complain.

A fix could be to add in valprint() function :

      /* Arrays of zero length are OK, just print {} */

	  if (TYPE_LENGTH (type) == 0) {
	  if (arrayprint)
	    print_spaces_filtered (2 + 2 * recurse, stream);
	  fprintf_filtered (stream, "{}");
	  break;
	  }

      /* Array of unspecified length: treat like pointer to first elt.  */

Please give me your comments.
Regards
Pierre Willard

PS : The following shows the problem :

psi:/usr2/pierre:cat pw.c

struct FOO {
  unsigned int bar;
  unsigned int foo[0];
} xxx;

main()
{

}
psi:/usr2/pierre:gcc -v -g -o pw pw.c
Reading specs from /usr/local/lib/gcc-lib/sun4/2.1/specs
gcc version 2.1
 /usr/local/lib/gcc-lib/sun4/2.1/cpp -lang-c -v -undef -D__GNUC__=2 -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__sparc -D__sun -D__unix -g pw.c /usr/tmp/cca19786.i
GNU CPP version 2.1 (sparc)
 /usr/local/lib/gcc-lib/sun4/2.1/cc1 /usr/tmp/cca19786.i -quiet -dumpbase pw.c -g -version -o /usr/tmp/cca19786.s
GNU C version 2.1 (sparc) compiled by GNU C version 2.1.
 as -o pw.o /usr/tmp/cca19786.s
 /usr/local/lib/gcc-lib/sun4/2.1/ld -e start -dc -dp -o pw /lib/crt0.o -L/usr/local/lib/gcc-lib/sun4/2.1/ -L/usr/local/lib/ pw.o -lgcc -lc -lg -lgcc
psi:/usr2/pierre:gdb pw
GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.5, Copyright 1992 Free Software Foundation, Inc...
(gdb) p xxx
$1 = {bar = 0, foo = Value not integer or pointer.
(gdb) 
Technical Details
Message-ID: <9209180052.AA12168@_la.tce.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!convex!darwin.sura.net!spool.mu.edu!uwm.edu!linac!pacific.mps.ohio-state.edu!cis.ohio-state.edu!la.tce.COM!pierre

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f5053,260375b8d7c51b91,start
X-Google-Attributes: gidf5053,public
X-Google-ArrivalTime: 1992-09-18 01:28:32 PST
Newsgroups: gnu.gdb.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!convex!darwin.sura.net!spool.mu.edu!uwm.edu!linac!pacific.mps.ohio-state.edu!cis.ohio-state.edu!la.tce.COM!pierre
From: pierre@la.tce.COM (Pierre Willard)
Subject: print of zero length arrays
Message-ID: <9209180052.AA12168@_la.tce.com>
Sender: gnulists@ai.mit.edu
Reply-To: pierre@la.tce.com
Organization: GNUs Not Usenet
Distribution: gnu
Date: Fri, 18 Sep 1992 00:52:32 GMT
Approved: bug-gdb@prep.ai.mit.edu
Lines: 55