[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bug in 2.91.66, 2.95.2 and 2.96
From: |
Sean Clarke |
Subject: |
Bug in 2.91.66, 2.95.2 and 2.96 |
Date: |
Sun, 22 Oct 2000 21:54:29 +0100 |
Hi,
I posted this in gnu.gcc.bug, then realised it would be more
appropriate here :-)
There appears to be a bug in gcc, can someone confirm ?. Attached is a
cpp file that demonstrates the problem which seems to cause the compiler
to call one (or more) too many destructors, we detected the problem
whilst porting an HP application to Linux and traced the core dumps etc.
to some code that wasn't too well written
(i.e. it was passing the object by value instead of by reference) anyway
it appears the compiler does something horrible, calls too many
destructors, and when we try to delete the object/use the object....
BANG.
Is anyone able to fix this problem ?
--
regards
Sean Clarke
=============================================
www.linux-software.clara.co.uk
address@hidden
Linux... for those whose IQ is greater than 98 !!!
#include <utility>
#include <list>
#include <iostream>
class Counter
{
public:
Counter();
~Counter() throw();
Counter( const Counter& rhs);
static int count() { return count_; }
private:
static int count_;
int state;
};
Counter::Counter()
{
++count_;
cout << "Counter::Counter() count_=" << count_ << endl;
}
Counter::~Counter() throw()
{
--count_;
cout << "Counter::~Counter() count_=" << count_ << endl;
}
Counter::Counter( const Counter& rhs)
{
++count_;
cout << "Counter::Counter() count_=" << count_ << endl;
}
int Counter::count_ = 0;
class Returns_pair
{
public:
typedef pair< Counter, Counter > Returns;
Returns pair() const;
};
Returns_pair::Returns Returns_pair::pair() const
{
return Returns();
}
class Holder
{
public:
Holder( Counter counter ) : counter_( counter ) {}
private:
Counter counter_;
};
int main()
{
cout << "In main" << endl;
list< Holder > list;
Returns_pair returns_pair;
list.push_back( Holder( returns_pair.pair().first ) );
cout << Counter::count() << " should be 1" << endl;
return 0;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Bug in 2.91.66, 2.95.2 and 2.96,
Sean Clarke <=