Defect Report #007

Submission Date: 10 Dec 92
Submittor: WG14
Source: X3J11/90-043 (Paul Eggert)
Question 1
Are declarations of the form struct-or-union identifier ; permitted after the identifier tag has already been declared? Here are some examples of the problem:
/*1*/ struct s;
/*
2*/ struct s;
/*
3*/ struct s {int a;};
/*
4*/ struct s;
/*
5*/ struct t {int a;};
/*
6*/ struct t;
Subclause 6.5 says ``A declaration shall declare at least a declarator, a tag, or the members of an enumeration.'' In this sense, does /*2*/ also declare the tag s? If so, then surely all of the above lines are conforming. But if not, then in what sense does /*3*/ declare a tag and thus satisfy subclause 6.5's constraint?
The example at the end of subclause 6.5.2.3 says ``To eliminate this context sensitivity, the otherwise vacuous declaration struct s2; may be inserted ...'' This seems to imply that /*2*/, /*4*/, and /*6*/ are not conforming, because the y are vacuous. But how can this be reconciled with the above argument?
Response
The declaration
struct s;
declares the tag s. It need not be the first or only declaration of the tag s within a given scope to qualify as a declaration of s, just as
int i;
declares i however often it is repeated. The applicable constrai nt is in subclause 6.5: ``A declaration shall declare at least a declarator, a tag, or the members of an enumeration.'' Clearly,
struct s;
declares the tag s.
Subclause 6.5.2.3, in the examples, characterizes a declaration of this form as ``otherwise vacuous'' in the draft you read. The words ``otherwise vacuous'' were an editorial comment that was omitted from the International Standard. These words were intended to mean ``other than declaring s2 to be an (incomplete) struct type,'' and should not be read as saying that the declaration fails to declare the tag.
We believe that this interpretation is consistent with the intent of the Committee, and that a reasonable reading of the standard supports this interpretation.
Previous Defect Report < - > Next Defect Report