Created on 1999-12-20.00:00:00 last changed 208 months ago
Proposed resolution (10/00):
Add the following as paragraph 3 of C.1.4 [diff.expr]:
5.16, 5.17, 5.18
Change: The result of a conditional expression, an assignment expression, or a comma expression may be an lvalue.
Rationale: C++ is an object-oriented language, placing relatively more emphasis on lvalues. For example, functions may return lvalues.
Effect on original feature: Change to semantics of well-defined feature. Some C expressions that implicitly rely on lvalue-to-rvalue conversions will yield different results. For example,char arr; sizeof(0, arr)yields 100 in C++ and sizeof(char*) in C.
Difficulty of converting: Programs must add explicit casts to the appropriate rvalue.
How widely used: Rare.
char arr; sizeof(0,arr);
What does the sizeof expression return? According to 8.19 [expr.comma] paragraph 1, the comma operator yields an lvalue if the second argument is an lvalue. Since 7.2 [conv.array] paragraph 1 says that the array-to-pointer conversion yields an rvalue, it seems that sizeof should see an array type and give the answer 100. If so, the value of the sizeof expression would be different from that of the corresponding expression in C, but there is nothing in Annex C [diff] to indicate that an incompatible change was intended.
|2003-04-25 00:00:00||admin||set||status: dr -> tc1|
|2000-11-18 00:00:00||admin||set||status: ready -> dr|
|2000-05-21 00:00:00||admin||set||messages: + msg306|
|2000-05-21 00:00:00||admin||set||status: open -> ready|