Article View: comp.std.c
Article #4374Re: "Size not needed?"
From: Paul Long
Date: Fri, 17 Nov 1995 18:51
Date: Fri, 17 Nov 1995 18:51
42 lines
2556 bytes
2556 bytes
rich@kastle.com (Richard Krehbiel) wrote:
>Paul Long <plong@perf.com> wrote:
>
>>Section 6.5.2.3 says, "If a type specifier of the form _struct-or-union
>>identifier_ occurs prior to the declaration that defines the content, the
>>structure or union is an incomplete type. It declares a tag that specifies a
>>type that may be used only when the size of an object of the specified type is
>>not needed."
>
>>What does "the size...is not needed" mean? "Needed" sounds awfully vague. For
>>example, is the size needed here?
>
>> struct S x;
>> void foo() { x; }
>
>>I don't think so, but perhaps this is implementation-dependent.
>
>I think the size is needed, but not because of the reference in foo(),
>but because of the way it's defined. Since x is of static storage
>class, the language is obliged to initialize it, and it can't without
>knowing the size.
I didn't say so, but I was really looking for references to the Standard
to back up any arguments.
Regarding your response, one could argue that, even though the object
has static storage duration, because the object has incomplete type,
there are no members to initialize; therefore, "the size is not needed."
Specifically, the Standard says in 6.5.7, "The type of the entity to be
initialized shall be an object type or an array of unknown size." My
example is neither--it is an incomplete type, so it is not "initialized
implicitly" (also from section 6.5.7).
This is not necessarily my position. though. I'm just trying to find in
the Standard exactly what I'm supposed to do as an implementor.
--
Paul Long plong@perf.com http://www.teleport.com/~pciwww/
"A perfect method should not only be an efficient one, as respects
the accomplishment of the objects for which it is designed, but
should in all its parts and processes manifest a certain unity and
harmony." - George Boole, _An Investigation of the Laws of Thought_
Technical Details
Message-ID:
<48iljp$jl5@news0.rain.rg.net>Path:
arc1-ca.pugleaf.net!homer.alpha.net!pacifier!rainrgnews0!usenetReferences:
<48gu0r$91o@news0.rain.rg.net> <1995Nov17.120551.23493@friend.kastle.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!homer.alpha.net!pacifier!rainrgnews0!usenet From: Paul Long <plong@perf.com> Newsgroups: comp.std.c Subject: Re: "Size not needed?" Date: 17 Nov 1995 18:51:37 GMT Organization: Performance Computing Incorporated Message-ID: <48iljp$jl5@news0.rain.rg.net> References: <48gu0r$91o@news0.rain.rg.net> <1995Nov17.120551.23493@friend.kastle.com> NNTP-Posting-Host: yosemite.perf.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 1.1N (X11; I; SunOS 4.1.1 sun4c) X-URL: news:1995Nov17.120551.23493@friend.kastle.com