473,385 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

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 2860
On Jun 21, 4:33 am, Lighter <cqu...@gmail.comwrote:
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 conversions are 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.
Well, it means that the lvalue-to-rule, array-to-pointer and
function-to-pointer conversions are not applied to the left
operand of a comma operator. That seems clear enough, per se;
what part don't you understand?

In general, I can't really see how a conforming program could
tell whether they were applied or not. For example, if I write:

int array[ 10 ] ;

array, f() ;

how can I possibly know whether the type of the right operand of
the comma is int[10] or int*? And how can it matter?

I suppose that it is really only significant with regards to
whether the type must be complete, or whether there must be a
definition.

class C ;
C* pC ;

*pC, f()

is legal, but it wouldn't be if an lvalue-to-rvalue conversion
took place (since the standard requires a complete type any time
there is an lvalue-to-rvalue conversion). Similarly, given:

extern int g() ;
extern int a[] ;

g, f() ;
a, f() ;

I think (but I'm far from sure) the fact that the function to
pointer conversion doesn't take place on g means that g is not
used in this expression, and thus that no definition is
required. And the same thing holds for a, because the
array-to-pointer conversion doesn't take place.

At any rate, that's the only real relevance I can see.

--
James Kanze (GABI Software, from CAI) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Jun 21 '07 #2
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
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
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 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;
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
On Jun 21, 12:32 pm, Lighter <cqu...@gmail.comwrote:
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:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Jun 21 '07 #6
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: python newbie | last post by:
Hi, I have a wxPython app which dump errors when I close it ( in the debug output at bottom of Komodo, when I close my app. ) Where I got the code for my GUI: Straight from the wxProject.py...
6
by: Kalle Anke | last post by:
Those who have read my posts today have probably understood that I'm not a "true" Python programmer ... but I want to learn more (I think that Python is rather fun). I've read "Learning Python"...
3
by: Alan Howard | last post by:
Hi there, I can't seem to find any info on this error message that's generated when sending email with CDO: "The pickup directory path is required and was not specified" Does anyone know...
5
by: Jim | last post by:
Is The C++ Programming Language (by Stroustrup)a good book for learning C++ programming or it is just a good book for reference? Thanks!
6
by: TS | last post by:
Hi, i have a problem validating xml against schema. I used http://apps.gotdotnet.com/xmltools/xsdvalidator/Default.aspx validator and it says it is fine. Can you tell me why this doesn't work? ...
9
by: Dullme | last post by:
i can hardly know what is the code for this. I have researched palindromes, but unfortunately, I only have read about integers not for characters..I need some help..
4
by: =?Utf-8?B?TWFyc2hhbGw=?= | last post by:
In the sentence, "Our efforts in serving "The Pearson Family" span several years," do you capitalize "The" and "Family"?
10
by: Roger | last post by:
ms-access97 & sql server2005 two tables tblItem tblItemFeature form frmItem contains subform frmItemFeature each form is based on their respective table creating new record and filling in...
2
by: gbin,Zhou | last post by:
Hi,all. I see from "http://docs.python.org/tut/node11.html" that "Name spaces are created at different moments and have different lifetimes. The namespace containing the built-in names is created...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.