473,396 Members | 2,092 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,396 software developers and data experts.

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
Nov 13 '05 #1
8 1468
In <48********@shepjeng.twbbs.org> GA************@shepjeng.twbbs.org (³á³á³á³á) writes:

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
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 13 '05 #2
Da*****@cern.ch (Dan Pop) wrote in message news:<bj**********@sunnews.cern.ch>...
In <48********@shepjeng.twbbs.org> GA************@shepjeng.twbbs.org (³á³á³á³á) writes:

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.


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

Nov 13 '05 #3
In article <41**************************@posting.google.com >,
Mantorok Redgormor wrote:
Da*****@cern.ch (Dan Pop) wrote in message
news:<bj**********@sunnews.cern.ch>...

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


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.
--
Andreas Kähäri
Nov 13 '05 #4
Mantorok Redgormor wrote:
Da*****@cern.ch (Dan Pop) wrote in message news:<bj**********@sunnews.cern.ch>...
In <48********@shepjeng.twbbs.org> GA************@shepjeng.twbbs.org (³á³á³á³á) writes:
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.


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


And how does it matter which part of i is evaluated first?

Jirka

Nov 13 '05 #5
GA************@shepjeng.twbbs.org wrote:
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

Nov 13 '05 #6
Thomas Matthews <Th**********************@sbcglobal.net> wrote:
GA************@shepjeng.twbbs.org wrote:
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.

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
Nov 13 '05 #7
³á³á³á³á wrote:

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 ?

--
pete
Nov 13 '05 #8
On 11 Sep 2003 11:36:02 GMT, GA************@shepjeng.twbbs.org
(³á³á³á³á) wrote:

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
Nov 13 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

39
by: Marco Aschwanden | last post by:
Hi I don't have to talk about the beauty of Python and its clear and readable syntax... but there are a few things that striked me while learning Python. I have collected those thoughts. I am...
3
by: fdsl ysnh | last post by:
--- python-list-request@python.orgдµÀ: > Send Python-list mailing list submissions to > python-list@python.org > > To subscribe or unsubscribe via the World Wide Web, > visit >...
14
by: Fred H | last post by:
I'm reading a STL book right now, and there I've picked up the folowing syntax: class C { private: int value; public: C(int initValue) : value(initValue) { } }
105
by: Christoph Zwerschke | last post by:
Sometimes I find myself stumbling over Python issues which have to do with what I perceive as a lack of orthogonality. For instance, I just wanted to use the index() method on a tuple which does...
3
by: neilcancer | last post by:
My English is poor... There are some sort algorithms which sort a sequencial list. The sequencial list was defined in "list-seq.h". sort_and_time() accepts one of these sort functions. It uses...
2
by: TheRomance | last post by:
i have a problem about insert integer to link list. sorry it's too long but i try many times, many ways , it's still have an error function is fix . can't change anything about function. i...
10
by: chrisben | last post by:
Hi, Here is the scenario. I have a list of IDs and there are multiple threads trying to add/remove/read from this list. I can do in C# 1. create Hashtable hList = Hashtable.Synchronized(new...
75
by: Steven T. Hatton | last post by:
No, this is not a troll, and I am not promoting Java, C-flat, D, APL, Bash, Mathematica, SML, or LISP. A college teacher recently posted to this newsgroup regarding her observation that there has...
10
by: Ruan | last post by:
My confusion comes from the following piece of code: memo = {1:1, 2:1} def fib_memo(n): global memo if not n in memo: memo = fib_memo(n-1) + fib_memo(n-2) return memo I used to think that...
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.