Defect Report #113
Submission Date: 03 Dec 93
Source: Ron Guilmette
ANSI/ISO C Defect report #rfg20:
Subject: Return expressions in functions declared to return qualified
a) Does the following code involve usage which requires
a diagnostic from a conforming implementation?
b) Does the following code involve usage which renders the
code itself not strictly conforming?
volatile void func0 (volatile void *vvp)
return *vvp; /* ? */
const void func1 (const void *cvp)
return *cvp; /* ? */
Subclause 18.104.22.168 (Constraints):
A return statement with an expression
shall not appear in a function whose
return type is void.
Note that this constraint doesn't say anything about functions declared
to return some qualified version of the void type.
I believe that it was probably the Committee's true intent to require
a diagnostic for any attempt to specify an expression in a return
statement within any function declared to return any qualified
or unqualified version of the void type (and indeed, many existing
implementations do already issue diagnostics for usage such as that
shown in the example above). Thus, it would seem appropriate for the
Committee to amend the above quoted constraint
(from subclause 22.214.171.124) to read:
A return statement with an expression shall not appear
in a function whose return type is a void type.
a) Yes, a diagnostic is required.
b) Yes, this renders the program not strictly conforming
A qualified void function return type
is disallowed by the constraints of subclause 6.7.1:
The return type from a function shall be void
or an object type other than array.
The constraint does not say ``a void type'' and thus void
must not be qualified when used as a function return type. Since a
qualified void return type
is already invalid, there is no need for
the additional constraint on the
return statement (subclause 126.96.36.199).
Previous Defect Report
< - >
Next Defect Report