Re: How to read "The lvalue-to-rvalue, array-to-pointer, and function-to-pointer standard conversionsare not applied to the left expressions"?
On Jun 21, 12:32 pm, Lighter <cqu...@gmail.com> wrote:
Thank you very much, James.
Please see an example:
int a[2];
int* p;
int* p2 = (p = a, p++); // Note here, p = a is a array-to-pointer
conversion.
OK. I understand where your problem is.
"p = a" is not an array-to-pointer conversion, because the type
of "p = a" is int*; the type of an assignment expression is
always the type of the lvalue being assigned.
There is an array-to-pointer conversion *in* the expression, but
the expression itself isn't subject to the conversion: if the
results of "p = a" were an array, no conversion would take
place. The expression "a" is not the expression to the right of
the comma operator; the expression "p = a" is. The expression
"a" is the expression to the left of an assignment operator,
where the rvalue to lvalue conversion takes place (which
automatically means that the array-to-pointer conversion is
active).
the code above can be compiled without any warning with VS 2005. Why?
Because it's legal.
What is the reason of the standard's making such a rule? That is what
I really want to see. Could give me an explaination?
See above. The text concerns only the operands of the comma
operator. The sub-expressions of that expression are not
concerned.
--
James Kanze (GABI Software, from CAI) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34