Movatterモバイル変換


[0]ホーム

URL:


Issue 1383 - WG21 CWG Issues
Title
Clarifying discarded-value expressions
Status
cd3
Section
Clause [7] [expr]
Submitter
Lawrence Crowl

Created on2011-08-30.00:00:00 last changed48 months ago

Messages

msg6704 (view)
Date: 2012-10-15.00:00:00

[Moved to DR at the October, 2012 meeting.]

msg4126 (view)
Date: 2012-02-15.00:00:00

Additional note (February, 2012):

A problem was discovered that was not addressed by the proposedresolution that was reviewed at the February, 2012 meeting, so theissue has been moved back to "review" status with revised wording.

msg3696 (view)
Date: 2012-02-15.00:00:00

Proposed resolution (February, 2012):

Change Clause 7 [expr] paragraph 10 as follows:

...The lvalue-to-rvalue conversion (7.3.2 [conv.lval]) isappliedif and only if the expression is an lvalue ofvolatile-qualified type and ithasis one of thefollowingforms:

  • (expression), whereexpression is one of these expressions,

  • id-expression (_N4567_.5.1.1 [expr.prim.general]),

  • ...

  • conditional expression (7.6.16 [expr.cond]) where boththe second and the third operands are one ofthe abovethese expressions, or

  • comma expression (7.6.20 [expr.comma]) where the rightoperand is one ofthe abovetheseexpressions.

[Note: Using an overloaded operator causes a functioncall; the above covers only operators with built-in meaning. If thelvalue is of class type, it must have a volatile copy constructor toinitialize the temporary that is the result of the lvalue-to-rvalueconversion. —end note]

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

Suggested resolution:

In some contexts, an expression only appears for its sideeffects. Such an expression is called adiscarded-valueexpression. The expression is evaluated and its value isdiscarded. The array-to-pointer (7.3.3 [conv.array]) andfunction-to-pointer (7.3.4 [conv.func]) standardconversions are not applied. The lvalue-to-rvalue conversion(7.3.2 [conv.lval]) is appliedif and only ifthe expression is an lvalue of volatile-qualified type and it hasone of the following forms:

  • id-expression (_N4567_.5.1.1 [expr.prim.general]),

  • subscriptingsubscript operation(7.6.1.2 [expr.sub]),

  • class member access (7.6.1.5 [expr.ref]),

  • indirectionoperation (7.6.2.2 [expr.unary.op]),

  • pointer-to-member operation (7.6.4 [expr.mptr.oper]),

  • conditionalexpressionoperation(7.6.16 [expr.cond]) where both the second and the thirdoperands are one ofthe abovethese forms,or

  • commaexpressionoperation(7.6.20 [expr.comma]) where the right operand is one oftheabovethese forms.

[Note: Expressions invoking user-defined operatorsare not the operations above. Discarded-value expressions applyto class types, which will be ill-formed if there is no volatilecopy constructor with which to initialize thetemporary. —end note]

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

There are some points in the description discarded-value expressionsthat need clarification:

  • Does this require the lvalue-to-rvalue conversion inthe listed cases or only prohibit it in all other cases(“only if” vs “if and only if”)?

  • Does this apply only to built-in operations or to overloadedoperators?

  • Does this apply to non-POD types?

History
DateUserActionArgs
2022-02-18 07:47:23adminsetmessages: +msg6704
2014-03-03 00:00:00adminsetstatus: drwp -> cd3
2013-05-03 00:00:00adminsetstatus: dr -> drwp
2012-11-03 00:00:00adminsetmessages: +msg4126
2012-11-03 00:00:00adminsetstatus: ready -> dr
2012-02-27 00:00:00adminsetmessages: +msg3696
2012-02-27 00:00:00adminsetmessages: +msg3695
2012-02-27 00:00:00adminsetstatus: open -> ready
2011-08-30 00:00:00admincreate

[8]ページ先頭

©2009-2026 Movatter.jp