From: Robert Gallant (rgallant@morgan.ucs.mun.ca)
Date: 08/09/93


From: rgallant@morgan.ucs.mun.ca (Robert Gallant)
Subject: BIZZARE g++ 2.3.3 behavior!!!!!
Date: Mon, 9 Aug 1993 19:12:20 GMT

Can anybody out there try to figure out why the three consecutive
cout << t;
statements at the end of this short program give different outputs!!!!!

//PROGRAM BEGINS HERE__________

#include "iostream.h"

class tuple
{
        int* element;
        
public:
        tuple();
        ~tuple();
        friend ostream& operator<<( ostream& stream, tuple tup );
};

tuple::tuple()
{
        element = new int [4];
        for(int i=0; i< 4; i++) element[i]=i;
}

tuple::~tuple()
{
        delete element;
}

ostream& operator<<(ostream& stream, tuple tup)
{
        int i;
        for(i=1; i< 4; i++)
        {
                stream << tup.element[i] ;
        }
        return stream;
}

main()
{
        tuple t;
        cout << t << "\n";
        cout << t << "\n";
        cout << t << "\n";
        cout << t << "\n";
}

On my computer the program prints
123
123
161142467623
2048023

!!!!!!!!!!!!!!!
If I'm being dumb flame me, not the net.
--Rob
rgallant@morgan.ucs.mun.ca