Movatterモバイル変換


[0]ホーム

URL:


Issue 188 - WG21 CWG Issues
Title
Comma operator and rvalue conversion
Status
tc1
Section
7.6.20 [expr.comma]
Submitter
Mike Miller

Created on1999-12-20.00:00:00 last changed277 months ago

Messages

msg306 (view)
Date: 2000-04-15.00:00:00

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.

msg251 (view)
Date: 2022-02-18.07:47:23

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
DateUserActionArgs
2003-04-25 00:00:00adminsetstatus: dr -> tc1
2000-11-18 00:00:00adminsetstatus: ready -> dr
2000-05-21 00:00:00adminsetmessages: +msg306
2000-05-21 00:00:00adminsetstatus: open -> ready
1999-12-20 00:00:00admincreate

[8]ページ先頭

©2009-2026 Movatter.jp