You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
p2 says "In simple assignment (=), the value of the expression replaces that of the object referred to by the left operand."
p3 says "If the left operand is not of class type, the expression is implicitly converted ([conv]) to the cv-unqualified type of the left operand.".
In especially p2, it's confusing that this says "expression", when both the left and right operands are expressions (in fact, the right operand is not always an expression, since it may be an initializer list!). I suggest
p2 says "In simple assignment (=), the value of the right operand replaces that of the object referred to by the left operand."
p3 says "If the left operand is not of class type, it is implicitly converted ([conv]) to the cv-unqualified type of the left operand.".
Secondly, for "scalar assignment-op { }" we are told "an assignment to a scalar, in which case the initializer list shall have at most a single element. The meaning of x = {v}, where T is the scalar type of the expression x, is that of x = T{v}. The meaning of x = {} is x = T{}". But what about compound assignment operator? Is it undefined behavior? The prior paragraph that supposedly defines compound assignment says "The behavior of an expression of the form E1 op= E2 is equivalent to E1 = E1 op E2 except that E1 is evaluated only once.". But "E1 + {}" is not valid. It is not clear what this means: A syntactic ill-formed construct shall be equivalent with a syntactic well-formed construct?
Compiler survey: Clang-3.8 accepts "int a = 0; a += { 2 }", GCC-7.2 rejects.
The text was updated successfully, but these errors were encountered:
This is really two issues. First,
p2 says "In simple assignment (=), the value of the expression replaces that of the object referred to by the left operand."
p3 says "If the left operand is not of class type, the expression is implicitly converted ([conv]) to the cv-unqualified type of the left operand.".
In especially p2, it's confusing that this says "expression", when both the left and right operands are expressions (in fact, the right operand is not always an expression, since it may be an initializer list!). I suggest
p2 says "In simple assignment (=), the value of the right operand replaces that of the object referred to by the left operand."
p3 says "If the left operand is not of class type, it is implicitly converted ([conv]) to the cv-unqualified type of the left operand.".
Secondly, for "scalar assignment-op { }" we are told "an assignment to a scalar, in which case the initializer list shall have at most a single element. The meaning of x = {v}, where T is the scalar type of the expression x, is that of x = T{v}. The meaning of x = {} is x = T{}". But what about compound assignment operator? Is it undefined behavior? The prior paragraph that supposedly defines compound assignment says "The behavior of an expression of the form E1 op= E2 is equivalent to E1 = E1 op E2 except that E1 is evaluated only once.". But "E1 + {}" is not valid. It is not clear what this means: A syntactic ill-formed construct shall be equivalent with a syntactic well-formed construct?
Compiler survey: Clang-3.8 accepts "int a = 0; a += { 2 }", GCC-7.2 rejects.
The text was updated successfully, but these errors were encountered: