coop3@watserv1.waterloo.edu (Scotte Zinn) (02/05/91)
I have the following program which, when run using TC1.01 command line
compiler, calls the constructor 4 times but only calls two destructors.
When compiled with G++ on UNIX, it only calls 3 constructors and 3
destructors. Is this a known bug with TC1.01???
Here is my sample program:
---Cut here---
#include <stdio.h>
class FooBar {
public:
FooBar();
FooBar(FooBar &x);
~FooBar();
};
FooBar::FooBar()
{
printf("ctor: FooBar()\n");
}
FooBar::FooBar(FooBar &x)
{
printf("ctor: FooBar(FooBar &)\n");
}
FooBar::~FooBar()
{
printf("dtor: FooBar()\n");
}
FooBar create1()
{
return FooBar();
}
FooBar create2()
{
return create1();
}
void main()
{
FooBar x = create2();
}
---Cut Here---
I can get around this by putting temporary variables in create1() and
create2(). I have also tried the TC++ version with an operator=() but
the same output occured.
Any comments would be appreciated.
-- Scotte Zinn
coop3@watserv1.uwaterloo.ca