🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #4369

Re: "Size not needed?"

#4369
From: Nick Maclaren
Date: Fri, 17 Nov 1995 10:57
35 lines
1676 bytes
In article <48gu0r$91o@news0.rain.rg.net>, Paul Long <plong@perf.com> writes:
|> 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.
|> How about this one:
|> 
|>    void bar(struct T x) { x; }
|> 
|> Is this a conforming program? Is a diagnostic required?

The size IS needed in both cases, and these are illegal.  I agree that
the standard is thoroughly obscure in this area.  As an example of where
it is not needed, try this:

       void bar(struct T *x) { x; }

Incidentally, never declare a struct inside a parameter list, because
the scope of the declaration is, well, unhelpful :-)


Nick Maclaren,
University of Cambridge Computer Laboratory,
New Museums Site, Pembroke Street, Cambridge CB2 3QG, England.
Email:  nmm1@cam.ac.uk
Tel.:  +44 1223 334761    Fax:  +44 1223 334679
Technical Details
Message-ID: <48hpr1$8ns@lyra.csx.cam.ac.uk>
Path: arc1-ca.pugleaf.net!lyra.csx.cam.ac.uk!nmm1
References: <48gu0r$91o@news0.rain.rg.net>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!lyra.csx.cam.ac.uk!nmm1
From: nmm1@cus.cam.ac.uk (Nick Maclaren)
Newsgroups: comp.std.c
Subject: Re: "Size not needed?"
Date: 17 Nov 1995 10:57:37 GMT
Organization: University of Cambridge, England
Message-ID: <48hpr1$8ns@lyra.csx.cam.ac.uk>
References: <48gu0r$91o@news0.rain.rg.net>
NNTP-Posting-Host: ursa.cus.cam.ac.uk