Defect Report #163

Submission Date: 16 Oct 95
Submittor: BSI
Source: Clive D.W. Feather
Submitted to BSI by Clive D.W. Feather .
In this Defect Report, identifiers lexically identical to those declared in standard headers refer to the identifiers declared in those standard headers, whether or not the header is explicitly mentioned.
This Defect Report has been prepared with considerable help from Mark Brader, Jutta Degener, Ronald Guilmette, and a person whose employment conditions require anonymity. However, except where stated, opinions expressed or implied should not be assumed to be those of any person other than myself.
Defect Report UK 011: Undeclared identifiers
The C Standard is not clear on whether the use of an undeclared identifier as a primary expression requires a diagnostic message.
Subclause 6.3.1 states that:
An identifier is a primary expression, provided it has been declared as designating an object (in which case it is an lvalue) or a function (in which case it is a function designator).
It has been suggested that if no declaration of some identifier is visible in the current scope when that identifier appears in an expression, the identifier is not a primary expression, and therefore the syntax of subclause 6.3.1 is violated (in other words, there is no valid parse for the expression). This would thus require a diagnostic for an undeclared identifier.
Is this interpretation correct? If yes, then it needs to be made clear that this does not prevent a previously undeclared function from being called by a strictly conforming program (see
If not, does an undeclared identifier require a diagnostic, and if so, why? If not, is this a deliberate policy, or is it a defect that needs correction?
Identifiers that designate objects must be declared and be visible before they can be primary expressions (subclause, An identifier is visible (i.e., can be used) ...). A reasonable person could interpret that if no declaration of some identifier is visible, the identifier cannot be a primary expression. This affects undeclared identifiers that are intended to be used as implicitly declared functions. The Committee's intent is that the C Standard be read in the following order:
1. 6.3.1 Primary expressions

2. Function calls
If the expression that precedes the parenthesized argument list in a function call consists solely of an identifier, and if no declaration is visible for this identifier, the identifier is implicitly declared exactly as if, in the innermost block containing the function call, the declaration
extern int identifier();
3. 6.3.1 Primary expressions
An identifier is a primary expression, provided it has been declared as designating ... a function (...).
However, a reasonable person may not interpret the current wording as having that meaning (i.e., it might not be read in that order). This needs to be clarified in the next revision of the C Standard.

Previous Defect Report < - > Next Defect Report