Article View: comp.os.msdos.programmer
Article #1877TC++1.0 bug -- Out-of-line inline functions
From: Jamshid Afshar
Date: Tue, 14 Aug 1990 22:09
Date: Tue, 14 Aug 1990 22:09
55 lines
2106 bytes
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
Technical Details
Message-ID:
<35971@ut-emx.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!ut-emx!walt.cc.utexas.edu!jamshidShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!ut-emx!walt.cc.utexas.edu!jamshid From: jamshid@walt.cc.utexas.edu (Jamshid Afshar) Newsgroups: comp.os.msdos.programmer Subject: TC++1.0 bug -- Out-of-line inline functions Keywords: Borland, C++, TC++, inline Message-ID: <35971@ut-emx.UUCP> Date: 14 Aug 90 22:09:34 GMT Sender: news@ut-emx.UUCP Reply-To: jamshid@walt.cc.utexas.edu (Jamshid Afshar) Organization: The University of Texas at Austin, Austin, Texas Lines: 55