4

I have the below two (related) questions.

  1. Is the order of execution of functions called on other function's parameters list defined by C or C++ standard?
  2. Does the actual calling convention used by the compiler influence the order of function execution in the below statement in C/C++?

    func1(func2(), func3());
    

Thanks for your answers.

David G
  • 94,763
  • 41
  • 167
  • 253
mrn
  • 959
  • 5
  • 15
  • 5
    No. Yes. No problem. – SwiftMango Mar 24 '15 at 19:30
  • 7
    @texasbruce: I would like to say no, no. What makes you say calling convention affect execution order? – Viktoria Andersson Mar 24 '15 at 19:32
  • 2
    Why do you say "yes" to the second one? I don't believe that stdcall, cdecl, pascal, register, or others define the order of evaluation of parameters. – abelenky Mar 24 '15 at 19:33
  • 2
    The [evaluation strategy](http://en.wikipedia.org/wiki/Evaluation_strategy) determines the order of function execution. The [calling convention](http://en.wikipedia.org/wiki/Calling_convention) does not. – Drew Dormann Mar 24 '15 at 19:36
  • @texasbruce "No" is the wrong answer. The standard does *define it*, but says it's "unspecified". You're also wrong about the second part. See [calling convention and evaluation order](http://stackoverflow.com/q/4401929/3920237) –  Mar 24 '15 at 19:37
  • unspecified is the same as not defined for me. It is the same as 'do as you please' so not defined. Different compiler venders will do different things. – Philip Stuyck Mar 24 '15 at 19:40
  • @PhilipStuyck [Unspecified means the standard "**defines**" a set of allowable behaviors"](https://stackoverflow.com/questions/2397984/undefined-unspecified-and-implementation-defined-behavior). –  Mar 24 '15 at 19:42
  • @remyabel might be but in the end you don't know what your compiler will do hence the result for you is undefined or you write compiler specific code. – Philip Stuyck Mar 24 '15 at 19:45
  • @PhilipStuyck The point is that the behavior is defined by the **standard**, like the question asks. –  Mar 24 '15 at 19:49

0 Answers0