Submitter: Joseph Myers (UK)
Submission Date: 2007-03-24>
Source: Joseph Myers <email@example.com>
Reference Document: ISO/IEC WG14 N1222
[*] in abstract
184.108.40.206#4 says that
* as an array size "can only
be used in declarations with function prototype scope", and
paragraph 5 says "If the size is an expression that is not an
integer constant expression: if it occurs in a declaration at
function prototype scope, it is treated as if it were replaced by
But is a type name in a function prototype a declaration, and
does it have function prototype scope? Scopes are only defined in
6.2.1 for identifiers, and such type names do not declare
identifiers. The presence of
[*] in the syntax for
abstract declarators suggests that
void f(int (*)[*]);
was intended to be valid and
void f(int (*)[a]);
was intended to be equivalent to it, but there are no
declarations at function prototype scope involved.
Similarly, what is "in" such a declaration? Is the following valid?
void f(int (*)[sizeof(int (*)[*])]);
[*] lies within a parameter
declaration, it's within an expression inside it; not one of the
declarators involved in declaring the identifier with function
Suggested Technical Corrigendum
220.127.116.11 paragraph 4, change "declarations with function prototype scope" to "the nested sequence of declarators or abstract declarators for a function parameter in a function declaration that is not a definition"; remove the footnote. Paragraph 5, change "declaration at function prototype scope" to "the nested sequence of declarators or abstract declarators for a function parameter in a function declaration that is not a definition".
There was consensus that the first example should be valid, and the second should be invalid.
Also see N1238.
Above reference to N1238 is not relevant.
It appears the issue hinges entirely on the point that a type-name is not a declaration and does not declare an identifier, and because of that it has no scope. Instead of adding complex wording to avoid using the term "scope" as suggested in the DR, it seems clearer to modify the definition of Scope such that it applies to type-name, which is described in 6.7.6 as "syntactically a declaration for a function or an object of that type that omits the identifier".
The Committee does not see a way to avoid this change, it seems to be safe. Not altogether satisfied with the aesthetics of this change, but this seems to be a satisfactory way forward.
As a special case, a type-name (which is not a declaration of an identifier) is considered to have a scope that begins just after the place within the type-name where the omitted identifier would appear were it not omitted.
Also add a forward reference to Type names (6.7.6).
18.104.22.168 paragraph 4, change
declarations with function prototype scopeto
declarations or type-names with function prototype scope
Previous Defect Report < - > Next Defect Report