🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #3090

order of evaluation

#3090
From: Bernd Anhaeupl
Date: Mon, 22 Jan 1996 16:39
50 lines
2460 bytes
In various places the DWP specifies, that the order of evaluation of
some expressions is unspecified. 

Some questions:

1.) Does this mean, that for example in the following function call

	f(a(...),b(....),c(....));

    a(...), b(...), c(...) may even be evaluated in parallel in a
    multitasking environment? 

    1a) Is a statement like the one above valid C++, if a(), b()
        and c() are using and modifying the same global variables
        --- What is the exact meaning of "sequence point" in section 5
        paragraph 4 of the april DWP in this context?

	      static global_variable;

	      int a(){.....; global_variable++; .....}
	      int b(){.....; global_variable++; .....}
	      int c(){.....; global_variable++; .....}

	Please think of the consequences. Even such basic operations
        like free store management (User defined operator new,...!)
        will access and modify global data (structures).

2.) Is it legal for a compiler to reorder the evaluation of
    the operator new and the constructor calls of some new expressions.
    For example, is it legal for a compiler to evaluate

	f(new a(new b()))             or    f2(new a, new b)   (see also question 1)
 
                       in the following order:

	tmp1=a::new(sizeof(a));             tmp1=a::new(sizeof(a))
	tmp2=b::new(sizeof(b));             tmp2=b::new(sizeof(b))
	tmp2.b();                           tmp1.a()
	tmp1.a(tmp2);                       tmp2.b() 
	f(tmp1);                            f2(tmp1,tmp2);

-- 
Bernd Anhaeupl			Tel.:  +49 9131 857787
LATE - Uni Erlangen			
Cauerstr. 7			Email: anhaeupl@late.e-technik.uni-erlangen.de
91058 Erlangen

[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <4e0dr0$aul@rznews.rrze.uni-erlangen.de>
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage
From: anhaeupl@late.e-technik.uni-erlangen.de (Bernd Anhaeupl)
Newsgroups: comp.std.c++
Subject: order of evaluation
Date: 22 Jan 1996 16:39:42 GMT
Organization: LATE, Uni. Erlangen-Nuernberg, Germany
Approved: clamage@eng.sun.com (comp.std.c++)
Message-ID: <4e0dr0$aul@rznews.rrze.uni-erlangen.de>
NNTP-Posting-Host: taumet.eng.sun.com
Content-Type: text
X-Nntp-Posting-Host: late4.e-technik.uni-erlangen.de
Content-Length: 1665
X-Lines: 46
Originator: clamage@taumet