Article View: comp.std.c
Article #21Re: arrays of incomplete type elements
From: Ronald F. Guilmette
Date: Wed, 28 Oct 1992 18:46
Date: Wed, 28 Oct 1992 18:46
61 lines
2823 bytes
2823 bytes
In article <2175@sdrc.COM> scjones@thor.sdrc.com (Larry Jones) writes:
+In article <1992Oct27.080515.9088@netcom.com>, rfg@netcom.com (Ronald F. Guilmette) writes:
+< I have it on good authority that code such as:
+<
+< typedef struct struct0 table [500];
+<
+< struct struct0 {
+< int member;
+< };
+<
+< table my_table;
+<
+< Is valid and permissible because the element type for the array type
+< is in fact "completed" prior to the end of the compilation unit.
+<
+< The claim I have heard made is that one or more of the x3j11 interpretation
+< rulings contained in the Technical Information Bulletin #1, supports
+< this view.
+<
+< On the other hand, I find some evidence *against* this view in the
+< standard itself. In 3.1.2.5 it says:
+<
+< "An array type describes a contiguously allocated nonempty set of
+< objects with a particular member object type, called the element
+< type."
+
+In fact, there's a footnote there (17) which explicitly says "Since
+object types do not include incomplete types, an array of incomplete
+type cannot be constructed." That sounds like pretty compelling
+evidence that the above typedef is, in fact, invalid. I can find no
+extant interpretations that address this specific point, only one that
+asks about "typedef int foo[];" which is a whole different case since
+the base type there is not incomplete, only the resulting array type.
+
+I believe that your example is clearly invalid.
OK. I'll buy that.
I assume that this also implies that the following declarations are invalid
(according to ANSI C):
typedef int two_d_type[][];
extern int two_d_object[][];
Now the *real* question is "Are standard conforming implementations required
to issue diagnostics for these declarations, and for the declaration of
the type `table' in my original example?"
Could someone please attempt to answer that? (Larry? Care to take a whack
at it?)
If so, somebody should tell the compiler vendors. (Several supposedly ANSI
compilers I've tested don't seem to issue diagnostics for these declarations.)
--
// Ron ("Loose Cannon") Guilmette
// uucp: ...uunet!lupine!segfault!rfg
// New new motto: Quality control is a state of mind.
// misc.forsale.computers ad, circa 2007:
// Used Cray wrist watch for sale; 25 bucks or best offer.
Technical Details
Message-ID:
<1992Oct28.184633.8363@netcom.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!ames!decwrl!decwrl!netcomsv!netcom.com!rfgReferences:
<1992Oct27.080515.9088@netcom.com> <2175@sdrc.COM>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c Path: arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!ames!decwrl!decwrl!netcomsv!netcom.com!rfg From: rfg@netcom.com (Ronald F. Guilmette) Subject: Re: arrays of incomplete type elements Message-ID: <1992Oct28.184633.8363@netcom.com> Organization: Netcom Online Communications Services (408-241-9760 login: guest) References: <1992Oct27.080515.9088@netcom.com> <2175@sdrc.COM> Date: Wed, 28 Oct 1992 18:46:33 GMT Lines: 61