[comp.os.msdos.programmer] TC++1.0 bug -- Out-of-line inline functions

jamshid@walt.cc.utexas.edu (Jamshid Afshar) (08/15/90)

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