Boost logo

Boost :

From: Marc Duflot (m.duflot_at_[hidden])
Date: 2002-10-24 05:07:42


Daniel Frey wrote:

> #include <iostream>
> using namespace std;
>
> struct X
> {
> X() { cout << "X"; }
> X( const X& ) { cout << "C"; }
> };
>
> X f()
> {
> return X();
> }
>
> X g()
> {
> X x;
> return x;
> }
>
> int main()
> {
> X x1( f() ); cout << endl;
> X x2( g() ); cout << endl;

I extended your code with the following lines

   X x3 = f() ; cout << endl;
   X x4 = g() ; cout << endl;

> }

To my surprise, the results for (x3,x4) are not the same as the ones for
(x1,x2) with some compilers :

g++ 3.0.4 :
XC
XCC
X
XC

intel C++ 6 :
XC
XC
X
X

SGI MIPSpro Compilers: Version 7.3.1.3m
XC
XC
X
X

g++ 2.95.3 and g++ 3.1 give the expected results :

g++ 2.95.3
X
XC
X
XC

g++ 3.1
X
X
X
X

-- 
Marc Duflot
http://vesta.ltas.ulg.ac.be/~duflot/

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk