The details are included in the comments of the following source file: ------------------------------------------------------------------ /* File: main.cpp */ #include <iostream> #include <string> using namespace std; struct T1 { string f() { cout << "f() called\n"; return string("1"); } string g() { cout << "g() called\n"; return string("2"); } }; struct T2 { void add(const string& i, const string &j) { } }; int main() { T2 t2; T1 t1; /* Consider the following line. I expect that t1.f() is called before t1.g(). But the real execution is: t1.g() is called before t1.f(). I compiled this program by: g++ main.cpp Version information: g++ (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5) */ t2.add(t1.f(), t1.g()); return 0; }
Not a bug. The ISO/ANSI C++ standard (unlike Java) allows the order within sequence points to be executed in any order.
That's a duplicate of...
...PR 11751. *** This bug has been marked as a duplicate of 11751 ***