🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #2857

Re: Pointers to Incomplete Types in Prototypes

#2857
From: Norman Diamond
Date: Tue, 07 May 1991 04:36
47 lines
2610 bytes
In article <kre.673334440@mundamutti.cs.mu.OZ.AU> kre@cs.mu.oz.au (Robert Elz) writes:

>Disclaimer: I know absolutely nothing about ANSI C ...

Well, a bit better than nothing.  I hope that your disclaimer hasn't
discouraged some other competent people from reading.

>I can't see how its possible for
>	type foo(struct bar *arg);
>to possibly be considered as any kind of a definition of the
                                            declaration
>struct tag "bar".  Whether "bar" is defined elsewhere or not,
                                     declared
>this is (and can only be) a reference to "bar".

The standard might have benefitted from distinguishing between tag
declarations and tag definitions, but it did not do so.

Anyway, when we adjust this statement to use the standard's words,
I think it is correct.

>Struct tags are (should be, surely) only [declared] in a context as
>	struct bar { ... };

As well as (SOMETIMES) in the vacuous case of
        struct bar;

>The question of the scope inside the function prototype can only
>possibly be relevant to names defined there, of which "bar" is not
>one in the above example.  It would be in
>	type foo(struct bar { ... } *arg);
>which would *always* be a meaningless prototype, regardless of
>whether bar was [declared] elsewhere or not.

Exactly.  (No other possibility, because
        type foo(struct bar;);
would be syntactically invalid.)

>It seems as if the compiler involved is treating the reference
>to bar in the first prototype above as a definition, as it hadn't
>seen a definition before.  That is surely a bug.

Yes.  No wonder I was dissatisfied with my previous posting on this
issue.  Something still seems wrong.
--
Norman Diamond       diamond@tkov50.enet.dec.com
If this were the company's opinion, I wouldn't be allowed to post it.
Technical Details
Message-ID: <1991May7.043654.4795@tkou02.enet.dec.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!dali.cs.montana.edu!uakari.primate.wisc.edu!sdd.hp.com!elroy.jpl.nasa.gov!decwrl!pa.dec.com!jrdzzz.jrd.dec.com!tkou02.enet.dec.com!jit533!diamond
References: <w!2g7+c@rpi.edu> <700@taumet.com> <cl3gg!n@rpi.edu> <683g+p#@rpi.edu> <kre.673334440@mundamutti.cs.mu.OZ.AU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!dali.cs.montana.edu!uakari.primate.wisc.edu!sdd.hp.com!elroy.jpl.nasa.gov!decwrl!pa.dec.com!jrdzzz.jrd.dec.com!tkou02.enet.dec.com!jit533!diamond
From: diamond@jit533.swstokyo.dec.com (Norman Diamond)
Newsgroups: comp.std.c
Subject: Re: Pointers to Incomplete Types in Prototypes
Message-ID: <1991May7.043654.4795@tkou02.enet.dec.com>
Date: 7 May 91 04:36:54 GMT
References: <w!2g7+c@rpi.edu> <700@taumet.com> <cl3gg!n@rpi.edu> <683g+p#@rpi.edu> <kre.673334440@mundamutti.cs.mu.OZ.AU>
Sender: usenet@tkou02.enet.dec.com (USENET News System)
Reply-To: diamond@jit533.enet@tkou02.enet.dec.com (Norman Diamond)
Organization: Digital Equipment Corporation Japan , Tokyo
Lines: 47