Bug 11363 - Execution order is not correct
Summary: Execution order is not correct
Status: RESOLVED DUPLICATE of bug 11751
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P2 critical
Target Milestone: 3.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-06-28 18:15 UTC by Qing Yang
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Qing Yang 2003-06-28 18:15:11 UTC
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;
}
Comment 1 Andrew Pinski 2003-06-28 18:20:13 UTC
Not a bug. The ISO/ANSI C++ standard (unlike Java) allows the order within sequence points to be 
executed in any order.
Comment 2 Wolfgang Bangerth 2004-08-13 15:39:06 UTC
That's a duplicate of... 
Comment 3 Wolfgang Bangerth 2004-08-13 15:39:31 UTC
...PR 11751. 

*** This bug has been marked as a duplicate of 11751 ***