Defect Report #076
Submission Date: 03 Dec 93
Source: Clive Feather
Item 13 - pointers to the end of arrays
Consider the following code extracts:
int a ;
/* ... */
p = &a;
int *n = NULL;
/* ... */
p = &*n;
In the first extract, is the assignment strictly conforming (with
p being set to the expression a + 10), or is the constraint
in subclause 22.214.171.124 violated because a is not an object?
Note that this expression is often seen in the idiom:
for (p = &a; p < &a; p++)
In the second extract, is the assignment strictly conforming (with
p being set to a null pointer), or is the constraint
in subclause 126.96.36.199
violated because *n is not an object?
/* ... */
If only one assignment is strictly conforming, what distinguishes
the two cases? If either assignment is strictly conforming, what distinguishes
it from the situation described in the following extract from the
response to Defect Report #012?
Given the following declaration:
the expression &*p is invalid. This is because *p is of
type void and so is not an lvalue, as discussed in the quote
from subclause 188.8.131.52 above. Therefore, as discussed in the quote
from subclause 184.108.40.206 above, the operand of the & operator
in the expression &*p is invalid because it is neither a function
designator nor an lvalue.
This is a constraint violation
and the translator must issue a diagnostic message.
This issue remains open. The C Standard as currently worded
has the following consequences:
1) Subclause 220.127.116.11 requires the operand of &
to be an lvalue designating an object; a is not an object.
2) Subclause 18.104.22.168 requires the operand of &
to be an lvalue; NULL is not an lvalue.
Since the use of either construct prevents a program from being strictly
conforming, the remaining portion of the question is not applicable.
However, the Committee is not entirely comfortable with these
restrictions and may decide to relax them in resolving this issue.
Previous Defect Report
< - >
Next Defect Report