About initializaion list

³

³á³á³á³á

int i = 3, j = i;

is this well-defined?

because someone says
"The order of evaluation of initializers is not defined."

--
|
 ___
(-_-)
<¡ä¡ä>¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w ªÅ´ßªª³õ shepjeng.twbbs.org ¢w¢w¢w
¡þ plum.cs.nccu.edu.tw
 
D

Dan Pop

int i = 3, j = i;

is this well-defined?
Yes.

because someone says
"The order of evaluation of initializers is not defined."

The order of evaluation of an expression used as initialiser is not
defined.

Dan
 
A

Andreas Kahari

(e-mail address removed) (Dan Pop) wrote in message


j = i; can't "i" be considered an expression or sub-expression?

Yes, but I'm not sure it makes sense to talk about the order of
evalutaion of a single variable.
 
T

Thomas Matthews

int i = 3, j = i;

is this well-defined?

because someone says
"The order of evaluation of initializers is not defined."
This issue can be resolved by using two lines:
int i = 3;
int j = i;

In the above statements, there is no ambiguity.

--
|
 ___
(-_-)
<???>?w?w?w?w?w?w?w?w?w?w?w?w?w?w?w?w ?W^???? shepjeng.twbbs.org ?w?w?w
?? plum.cs.nccu.edu.tw

WTF is the above crap?
Signatures should not contain ANSI escape sequences, since many
newsreaders don't interpret them.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
 
I

Irrwahn Grausewitz

Thomas Matthews said:
This issue can be resolved by using two lines:
int i = 3;
int j = i;

In the above statements, there is no ambiguity.
Where is the ambiguity in:

int i = 3, j = i;

then?

Irrwahn
--
do not write: void main(...)
do not use gets()
do not cast the return value of malloc()
do not fflush( stdin )
read the c.l.c-faq: http://www.eskimo.com/~scs/C-faq/top.html
 
P

pete

³á³á³á³á said:
int i = 3, j = i;

is this well-defined?

because someone says
"The order of evaluation of initializers is not defined.

Where does the standard say that ?
 
D

Dave Thompson

int i = 3, j = i;

is this well-defined?

because someone says
"The order of evaluation of initializers is not defined."

They are wrong. An initializer is a full-expression and the end of a
full-expression is a sequence point. 6.8p3.

Perhaps they intended, or meant and you misunderstood, that for a
single variable of aggregate type (array or struct) initialized by an
initializer-list, 6.7.8p23, "The order in which any side effects occur
among the initialization list expressions is unspecified.130)" "130)
In particular, the evaluation order need not be the same as the order
of subobject initialization." which must be textual order, p19.

- David.Thompson1 at worldnet.att.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,813
Messages
2,569,699
Members
45,489
Latest member
SwethaJ

Latest Threads

Top