Submitter: Project Editor (Larry Jones)
Submission Date: 2004-03-19
Source: Neil Booth
Reference Document: N/A
Subject: Incomplete types for function parameters
The standard appears to be contradictory with respect to whether a function parameter is permitted to have an incomplete type in a prototype other than the function definition.
If the function declarator is not part of a definition of that function, parameters may have incomplete type....But 6.7p7 says:
If an identifier for an object is declared with no linkage, the type for the object shall be complete by the end of its declarator...; in the case of function arguments [n.b., that should be parameters, not arguments] (including in prototypes), it is the adjusted type (see 184.108.40.206) that is required to be complete.
If the intent is to allow incomplete types, there do not appear to be any constraints forbidding constructions like:
void func(void parm);
The Committee agrees that “function arguments” should be “function parameters”. The cited text from 6.7p7 refers to the declarations of parameters in the definition of that function; each parameter declares an object whose adjusted type is required to be complete. Declarations of parameters in prototypes which are not part of the definition of that function are permitted to declare incomplete types. Whenever that function is called, arguments are implicitly converted to the types of the corresponding parameters; see 220.127.116.11p7. The requirements upon assignment require that the types of the corresponding parameters are complete types, at the point of calling the function. The constraint at 6.5.16p2 requires a modifiable lvalue for the left operand of assignment, and according to 18.104.22.168p1, a modifiable lvalue shall not have incomplete type.
The Committee agrees that there do not appear to be any constraints forbidding constructions like
void func(void parm);nor are any semantics provided for this construction.
in the case of function arguments (including in prototypes)to:
in the case of function parameters (including in prototypes)
Previous Defect Report < - > Next Defect Report