[Home]Spirit Notes

BOOST WIKI | RecentChanges | Preferences | Page List | Links List

Difference (from prior major revision) (no other diffs)

Removed: 4,62d3

Mysterious multiple destructor calls




Testing out the Boost signals lib, I wrote:


#include <boost/signal.hpp>
#include <iostream>

using namespace std;
using namespace boost;

struct X {
void operator()(int val) { cout << "X <- " << val << endl; }
X() { cout << "X constructor\n"; }
~X() { cout << "X destructor\n"; }
};


int main() {
{
cout << " phase 1\n";
signal<void (int)> sig;
cout << " phase 2\n";
X x;
cout << " phase 3\n";
sig.connect(x);
cout << " phase 4\n";
}
cout << " phase 5\n";

return 0;
}


The following output is generated (gcc3.2.2 on Mandrake 9.1):


phase 1
phase 2
X constructor
phase 3
X destructor
X destructor
X destructor
X destructor
X destructor
X destructor
X destructor
X destructor
phase 4
X destructor
X destructor
phase 5


Why the multiple calls to X's destructor? I'd have expected just one. It looks like the signals lib is misbehaving.

- Chuck

This is for discussion of the Boost Spirit parser framework.



BOOST WIKI | RecentChanges | Preferences | Page List | Links List
Edit text of this page | View other revisions
Last edited May 16, 2003 10:10 am (diff)
Search:
Disclaimer: This site not officially maintained by Boost Developers