ai.a...@gmail.com wrote:
> Maybe I am missing something, but I cannot find any clear wording about
> requirements of value category on operands of some built-in operators.
(snip)
> Therefore, I would like to ask experts where the corresponding wording is.
> Or, does the standard intentionally leave such requirements unspecified?
Here are some relevant words I could find in the current draft N3485 so
far.
3.10 [basic.lval] p1 (in a Note)
> The discussion of each built-in operator in Clause 5 indicates the
> category of the value it yields and the value categories of the operands
> it expects. For example, the built-in assignment operators expect that
> the left operand is an lvalue and that the right operand is a prvalue
> and yield an lvalue as the result.
5 [expr] p9
> Whenever a glvalue expression appears as an operand of an operator that
> expects a prvalue for that operand, the lvalue-to-rvalue (4.1),
> array-to-pointer (4.2), or function-to-pointer (4.3) standard
> conversions are applied to convert the expression to a prvalue.
These wordings both imply that there are corresponding wordings about
expected value categories for each operands of operators. But I could
find very little wordings. Here is an example about left operand of
assignment operator.
5.17 [expr.ass] p1
> The assignment operator (=) and the compound assignment operators all
> group right-to-left. All require a modifiable lvalue as their left
> operand and return an lvalue referring to the left operand.
There are some clear wordings about value category of *result* of some
operators, though.
FYI, the C standard is clear on this point.
C (N1570) 6.3.2.1 p2
> Except when it is the operand of the sizeof operator, the _Alignof
> operator, the unary & operator, the ++ operator, the -- operator, or the
> left operand of the . operator or an assignment operator, an lvalue that
> does not have array type is converted to the value stored in the
> designated object (and is no longer an lvalue); this is called lvalue
> conversion.
The lack of clear wordings about expected value categories of operands
for each operator looks like a defect of C++ standard, at least for me.
--
k_satoda