Article View: comp.std.c
Article #3619Re: are zero lengthed arrays allowed?
From: Larry Jones
Date: Wed, 02 Aug 1995 15:29
Date: Wed, 02 Aug 1995 15:29
26 lines
1953 bytes
1953 bytes
In article <3v8tc9$ud4@tornews.torolab.ibm.com>, dmm@neutron.torolab.ibm.com (Dave Mooney) writes: > Larry Jones <scjones@thor.sdrc.com> wrote: > > I would note that, despite the committee's insistence on not having zero > > size objects, the current standard does have exactly one case where > > these occur (although it doesn't acknowledge it) -- the "thingy" just > > past the end of an array that you're allowed to point to but not > > reference behaves, as far as I can tell, exactly like a zero-size > > object. > > There's also the thing that you get back from malloc(0) under > implementations that choose to return a unique pointer rather than NULL. > And the thingy that you reference with fread(ptr, 0, nmemb, stream). I'll give you the first, but not the second. The standard requires fread to return 0 when the size is zero -- if it were actually reading zero size objects, it should return nmemb instead. Since 0 is also the error return value, I think it's clear that specifying a size of zero is interpreted as an error (as malloc is allowed to) and no zero size object is involved. (Since this doesn't seem to be pertinent to C++, I've removed comp.std.c++ from the Newsgroups:). ---- Larry Jones, SDRC, 2000 Eastman Dr., Milford, OH 45150-2789 513-576-2070 larry.jones@sdrc.com (Note: news takes forever to get here -- if you want a quick reply, email) You can never really enjoy Sundays because in the back of your mind you know you have to go to school the next day. -- Calvin
Technical Details
Message-ID:
<3vo5l3$39u@info1.sdrc.com>Path:
arc1-ca.pugleaf.net!sdrc.com!thor!scjonesReferences:
<3uo582$8of@snlsu1> <3ur7gi$huu@newsbf02.news.aol.com> <3v8tc9$ud4@tornews.torolab.ibm.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sdrc.com!thor!scjones From: scjones@thor.sdrc.com (Larry Jones) Newsgroups: comp.std.c Subject: Re: are zero lengthed arrays allowed? Date: 2 Aug 1995 15:29:39 GMT Organization: SDRC Engineering Services Distribution: world Message-ID: <3vo5l3$39u@info1.sdrc.com> References: <3uo582$8of@snlsu1> <3ur7gi$huu@newsbf02.news.aol.com> <3v8tc9$ud4@tornews.torolab.ibm.com> NNTP-Posting-Host: thor.sdrc.com