🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.os.msdos.programmer
1 messages
1 total messages Started by Jamshid Afshar Tue, 14 Aug 1990 22:09
TC++1.0 bug -- Out-of-line inline functions
#1877
Author: Jamshid Afshar
Date: Tue, 14 Aug 1990 22:09
55 lines
2106 bytes
Hi.  I believe I have found a bug in TC++ 1.0.  It only appears to
happen when OUT-OF-LINE inline functions is set to on (to aid
debugging).  It seems that when an if() expression is
short-circuited, the destructors are called for any temporary
variables that would have been created had the expression not been
short-circuited.  The constructor for those temporaries are correctly
never called, so what you have is an often disastrous destructor call
on a garbage object.  Anybody else have other problems with
temporaries?  Please post any bug reports for TC++ to
comp.os.msdos.programmer.  I just wasted a day and a 1/2 hour
long-distance on this problem :-(.

output with Out-of-line inline funcs:
----
Constructor
Desctructor isok()=0
Desctructor isok()=1

output without Out-of-line inline funcs:
----
Constructor
Desctructor isok()=1

---------------------------------------------------
Compiled from IDE with out-of-line inine functions.
---------------- cut here -------------------------

#include <fstream.h>

const MAGIC_VALUE = 4;

class Dummy {
private:
int x;
public:
   Dummy() { x=MAGIC_VALUE; cout << "Constructor" << endl; }
   Dummy duplicate() { return *this; }
   int isok() { return x==MAGIC_VALUE; }
   ~Dummy() { cout << "Desctructor isok()=" << isok() << endl; }
};


int main()
{
   cout << "----" << endl;
   Dummy dummy;
   if (0 && dummy.duplicate().isok())
      cout << "Something's very wrong." << endl;
   return 0;
}

---------------- stop here -------------------------

--Jamshid Afshar
--jamshid@ccwf.cc.utexas.edu
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