429,615 Members | 1,961 Online
Need help? Post your question and get tips & solutions from a community of 429,615 IT Pros & Developers. It's quick & easy.

# How to read "The lvalue-to-rvalue, array-to-pointer, and function-to-pointer standard conversionsare not applied to the left expressions"?

 P: n/a How to read "The lvalue-to-rvalue, array-to-pointer, and function-to- pointer standard conversionsare not applied to the left expressions"? In 5.18 Comma operator of the C++ standard, there is a rule: "The lvalue-to-rvalue, array-to-pointer, and function-to-pointer standard conversionsare not applied to the left expressions" I could not understand what the rule means. I also searched the web and the groups and got nothing. Who can give me some tips? Many thanks in advance. Jun 21 '07 #1
6 Replies

 P: n/a On Jun 21, 4:33 am, Lighter

 P: n/a 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. the code above can be compiled without any warning with VS 2005. Why? 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? Jun 21 '07 #3

 P: n/a Lighter wrote: How to read "The lvalue-to-rvalue, array-to-pointer, and function-to- pointer standard conversionsare not applied to the left expressions"? In 5.18 Comma operator of the C++ standard, there is a rule: "The lvalue-to-rvalue, array-to-pointer, and function-to-pointer standard conversionsare not applied to the left expressions" I could not understand what the rule means. I also searched the web and the groups and got nothing. Who can give me some tips? Many thanks in advance. Generally, it's meaningless. Since the value is just discarded, the conversions don't happen. I'm not sure how you'd tell if they were to happen anyhow. int scalar = 0; int array[10] = { 0 }; void func(); int i = scalar , 0; i = array , 0; i = func , 0; Means the value scalar isn't converted to an rvalue, and array isn't converted to int*, and func isn't converted to void (*)(). Jun 21 '07 #4

 P: n/a Ron Natalie wrote: Lighter wrote: >How to read "The lvalue-to-rvalue, array-to-pointer, and function-to-pointer standard conversionsare not applied to the leftexpressions"?In 5.18 Comma operator of the C++ standard, there is a rule:"The lvalue-to-rvalue, array-to-pointer, and function-to-pointerstandard conversionsare not applied to the left expressions"I could not understand what the rule means. I also searched the weband the groups and got nothing.Who can give me some tips? Many thanks in advance. Generally, it's meaningless. Since the value is just discarded, the conversions don't happen. I'm not sure how you'd tell if they were to happen anyhow. int scalar = 0; int array[10] = { 0 }; void func(); int i = scalar , 0; i = array , 0; i = func , 0; I don't believe this should compile. You need parentheses around the comma expressions. > Means the value scalar isn't converted to an rvalue, and array isn't converted to int*, and func isn't converted to void (*)(). Take a look at this program: -------------------------------------- int main() { int a; a, 42; } -------------------------------------- IF lvalue-to-rvalue conversion were happening for 'a', then the program would have undefined behaviour because 'a' is uninitialised. I don't think there is any other real need/implication for the rule. V -- Please remove capital 'A's when replying by e-mail I do not respond to top-posted replies, please don't ask Jun 21 '07 #5

 P: n/a On Jun 21, 12:32 pm, Lighter

 P: n/a James. I'm grateful to you for your timely and helpful reply. However, I am still not clear. Maybe I didn't correctly describe my problem. So I reworded my problem and started a new thread at: http://groups.google.com/group/comp....037a6653?hl=en Please visit the post and give your precious tips. Thanks in advance. Jun 21 '07 #7

### This discussion thread is closed

Replies have been disabled for this discussion.