Defect Report #064
Submission Date: 03 Dec 93
Source: Clive Feather
Item 1 - Null pointer constants
Consider the following translation unit:
char *f1 (int i, int *pi)
*pi = i;
char *f2 (int i, int *pi)
return (*pi = i, 0);
In f1, the 0 is a null pointer constant (subclause 18.104.22.168).
Since return acts as if by assignment (subclause 22.214.171.124) the
function is strictly conforming.
In f2, the 0 is a null pointer constant. However, a constant
expression cannot contain a comma operator (subclause 6.4), and so
the expression being returned is not a null pointer constant per se.
Which of the following is the case?
- The property of being a null pointer constant percolates upwards
through an expression, and the function f2 is strictly conforming.
- The property of being a null pointer constant does not percolate
upwards, and the expression being notionally assigned in the return
statement, though of value zero, is not a null pointer constant but
only of type int, thus violating a constraint (subclause 126.96.36.199).
Function f2 is not strictly conforming, because it violates
a constraint for simple assignment (which applies to converting the
type of the return expression), because the return expression
is not a null pointer constant.
Previous Defect Report
< - >
Next Defect Report