Created on1999-12-20.00:00:00 last changed277 months ago
Proposed resolution (10/00):
Add the following as paragraph 3 of C.7.4 [diff.expr]:
5.16, 5.17, 5.18
Change: The result of a conditional expression, anassignment expression, or a comma expression may be an lvalue.
Rationale: C++ is an object-oriented language, placingrelatively more emphasis on lvalues. For example, functions may returnlvalues.
Effect on original feature: Change to semantics of well-definedfeature. Some C expressions that implicitly rely on lvalue-to-rvalueconversions will yield different results. For example,char arr[100]; sizeof(0, arr)yields100 in C++ andsizeof(char*) in C.
Difficulty of converting: Programs must add explicit casts tothe appropriate rvalue.
How widely used: Rare.
Given
char arr[100]; sizeof(0,arr);
What does thesizeof expression return? According to7.6.20 [expr.comma] paragraph 1,the comma operator yieldsan lvalue if the second argument is an lvalue. Since7.3.3 [conv.array] paragraph 1says that thearray-to-pointer conversion yields an rvalue, it seems thatsizeof should see an array type and give the answer100.If so, the value of thesizeof expression would bedifferent from that of the corresponding expression in C, but thereis nothing in AnnexClause Annex C [diff]to indicate that an incompatible change was intended.
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 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 |
| 1999-12-20 00:00:00 | admin | create | |