Definition With Incomplete Type Should Be An Error

Karl Heuer karl at ima.isc.com
Thu Mar 28 11:42:40 AEST 1991


In article <509f2397.20b6d at apollo.HP.COM> blodgett at apollo.HP.COM (Bruce Blodgett) writes:
>Are my comments about the following program correct?  I feel that that
>the declarations of s1 and a2 should ideally require a diagnostic.

When you cross-post an article like this, you should include a warning that
you're doing so.  My comments apply to ANSI C, not C++.

>static int s1[]; /* Violates a "shall" requirement: */

Last time this came up, the conclusion was that, yes, this is illegal.
Personally, I think the Standard should have said that this is a declaration
rather than a tentative definition, and so it would only produce an error if
no actual definition is encountered.  (It would also have been nice if Dennis
had used keywords to distinguish declarations from definitions in the first
place, so we wouldn't need this tentative-definition kludge.  But there's no
point in dwelling on that.)

>extern void main(void) {
>    auto int a2[]; /* Undefined behavior? */
>}

Sounds right to me.  You've also misdeclared |main|, though; the Standard says
its return type is |int|, not |void|.

Karl W. Z. Heuer (karl at ima.isc.com or uunet!ima!karl), The Walking Lint



More information about the Comp.std.c mailing list