🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #6127

Re: "expandable" structs with last element declared using [1]

#6127
From: Wm E Davidsen Jr
Date: Thu, 21 Dec 1989 14:31
23 lines
1754 bytes
In article <4379@cuuxb.ATT.COM> mmengel@cuuxb.UUCP (Marc W. Mengel) writes:

| Gee guys, you *told* the compiler that foo->baz only has one
| character in it; of *course* it's wrong to reference 
| foo->baz[1].  

  Good point. Since this is a fairly common practice in C, I think there
would be room in a future version of the standard for a solution. I
*suggest* that it might be to allow the zero length declaration 
(int x[0]) as an explicit way of specifying just this type of struct
growth. It would, of course, disable subscript checking on that
particular array.

  I can't think of any use for it other than as the last element of a
struct, but there might be such. Any comments on the implications of
allowing this? I don't see a conflict with the existing standard, and
the practice of expanding a struct is certainly common, if not perfectly
portable under the ANSI rules.
-- 
bill davidsen	(davidsen@crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen)
"The world is filled with fools. They blindly follow their so-called
'reason' in the face of the church and common sense. Any fool can see
that the world is flat!" - anon
Technical Details
Message-ID: <1944@crdos1.crd.ge.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uwm.edu!rpi!crdgw1!crdos1!davidsen
References: <UZTerlu00VcJEDulRd@andrew.cmu.edu> <463@cpsolv.UUCP> <477@longway.TIC.COM> <468@bbxsda.UUCP> <4379@cuuxb.ATT.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uwm.edu!rpi!crdgw1!crdos1!davidsen
From: davidsen@crdos1.crd.ge.COM (Wm E Davidsen Jr)
Newsgroups: comp.std.c
Subject: Re: "expandable" structs with last element declared using [1]
Message-ID: <1944@crdos1.crd.ge.COM>
Date: 21 Dec 89 14:31:31 GMT
References: <UZTerlu00VcJEDulRd@andrew.cmu.edu> <463@cpsolv.UUCP> <477@longway.TIC.COM> <468@bbxsda.UUCP> <4379@cuuxb.ATT.COM>
Distribution: comp.std.c
Organization: GE Corp R&D Center, Schenectady NY
Lines: 23
Reply-exos: @crdgw1:To: davidsen@crdos1.crd.ge.com (bill davidsen)