🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: gnu.g++.lib.bug
1 messages
1 total messages Started by eric%bnrmtl%IRO.UMONTREAL.CA Fri, 02 Jun 1989 15:41
Strange Stream Behavior
#527
Author: eric%bnrmtl%IRO.UMONTREAL.CA
Date: Fri, 02 Jun 1989 15:41
67 lines
2103 bytes
A colleague has a strange problem trying to use libg++ 1.35 streams.
He sends me the following description.

---------------------------------------------------------------------------
/* Why does third item on line marked "BUG!" (line 27) not get printed? */

#include <stream.h>
#include <stdio.h>

class counter
{
  private:
    unsigned int value;
  public:
    counter(int init=5);
        counter( counter& );
    ~counter();
    unsigned int operator+ (counter);
};

main()
{
        int k ;

        counter c1;
        counter c2(7);

        // removing next line will result in core dump instead
        printf("int = %d\n", k);

        cout << "BUG!    "  << (c1+c2) << " Why not printed? \n";
        cout << "\n";

        // IF preceding/following 2 lines switched, get other results!!
        k = c1+c2;
        cout << "No bug  " << k     << " Printed. \n";
}

counter::counter(int init)
{
        value = init;
        cout << form("constructor %d\n", value);
}

counter::counter( counter& i )
{
        value = i.value;
    cout << form("call-by-value %d\n", value);
}

counter::~counter()
{
        cout << form("destructor %d \n", value);
}

unsigned int counter::operator+ (counter other)
{
        return value + other.value;
}

----------------------------------------------------------------------------


 ----------------------------------------------------------------------------
  Eric Brunelle  |    "C'est la nuit qu'il est beau de croire a la lumiere."
  BNR-Montreal   |                               -- E. Rostand
 ----------------------------------------------------------------------------
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads