I don't think this is a defect, but an editorial change could be applied to [expr.context]/2 to make it more clear.
[expr.context]/2 only specifies some special handlings of discard-value expressions. The answer to "exactly which expressions are discard-value expressions" is not in [expr.context]/2, but in [expr.static.cast]/6, [expr.comma]/1, and [stmt.expr]/1. Thus, it makes sense to at least add cross references to these places in [expr.context]/2.
________________________________________
From: Alexander <
alexandreter...@gmail.com>
Sent: Thursday, January 11, 2018 1:09:51 PM
To: ISO C++ Standard - Discussion
Subject: [std-discussion] I think this is a defect in [expr.context]/2
[expr.context]/2<
http://eel.is/c++draft/expr#context-2>:
2
In some contexts, an expression only appears for its side effects.<
http://eel.is/c++draft/expr#context-2.sentence-1>
Such an expression is called a discarded-value expression<
http://eel.is/c++draft/expr#def:discarded-value_expression>.<
http://eel.is/c++draft/expr#context-2.sentence-2>
The array-to-pointer<
http://eel.is/c++draft/conv.array> and function-to-pointer<
http://eel.is/c++draft/conv.func> standard conversions are not applied.<
http://eel.is/c++draft/expr#context-2.sentence-3>
The lvalue-to-rvalue<
http://eel.is/c++draft/conv.lval> conversion is applied if and only if the expression is a glvalue of volatile-qualified type and it is one of the following:
*
(2.1)<
http://eel.is/c++draft/expr#context-2.1>
(2.1) ( expression<
http://eel.is/c++draft/expr.comma#nt:expression> ), where expression<
http://eel.is/c++draft/expr.comma#nt:expression> is one of these expressions,
*
(2.2)<
http://eel.is/c++draft/expr#context-2.2>
(2.2) id-expression<
http://eel.is/c++draft/expr.prim.id#nt:id-expression>,
*
(2.3)<
http://eel.is/c++draft/expr#context-2.3>
(2.3) subscripting<
http://eel.is/c++draft/expr.sub>,
*
(2.4)<
http://eel.is/c++draft/expr#context-2.4>
(2.4) class member access<
http://eel.is/c++draft/expr.ref>,
*
(2.5)<
http://eel.is/c++draft/expr#context-2.5>
(2.5) indirection<
http://eel.is/c++draft/expr.unary.op#def:indirection>,
*
(2.6)<
http://eel.is/c++draft/expr#context-2.6>
(2.6) pointer-to-member operation<
http://eel.is/c++draft/expr.mptr.oper>,
*
(2.7)<
http://eel.is/c++draft/expr#context-2.7>
(2.7) conditional expression<
http://eel.is/c++draft/expr.cond> where both the second and the third operands are one of these expressions, or
*
(2.8)<
http://eel.is/c++draft/expr#context-2.8>
(2.8) comma expression<
http://eel.is/c++draft/expr.comma> where the right operand is one of these expressions.<
http://eel.is/c++draft/expr#context-2.8.sentence-1>
*
[ Note<
http://eel.is/c++draft/expr#context-2.note-1>
:
Using an overloaded operator causes a function call; the above covers only operators with built-in meaning.<
http://eel.is/c++draft/expr#context-2.sentence-8>
— end note
]
If the (possibly converted) expression is a prvalue, the temporary materialization conversion<
http://eel.is/c++draft/conv.rval> is applied.<
http://eel.is/c++draft/expr#context-2.sentence-6>
[ Note<
http://eel.is/c++draft/expr#context-2.note-2>
:
If the expression is an lvalue of class type, it must have a volatile copy constructor to initialize the temporary object that is the result object of the lvalue-to-rvalue conversion.<
http://eel.is/c++draft/expr#context-2.sentence-9>
— end note
]
The glvalue expression is evaluated and its value is discarded.<
http://eel.is/c++draft/expr#context-2.sentence-7>
The paragraph defines a discarded-value expression, only considering expressions of the type ( expression ), where any expression of the type expression; satisfying (2.2) to (2.8) is also a discarded-value expression. To correct this, it's enough to change (2.1) to this:
(2.1) expression; or (expression), where expression is one of these expressions,
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
std-discussio...@isocpp.org<mailto:
std-discussio...@isocpp.org>.
To post to this group, send email to
std-dis...@isocpp.org<mailto:
std-dis...@isocpp.org>.
Visit this group at
https://groups.google.com/a/isocpp.org/group/std-discussion/.