|
Boost : |
From: Giovanni Bajo (giovannibajo_at_[hidden])
Date: 2003-12-21 21:43:44
Beman Dawes wrote:
> Could you please put together a little program that illustrates the
> bug? I'm guessing it will help to have a complete program.
Sure.
-----------------------------------------------------------------------------
#include <iostream>
using namespace std;
template <typename DerivedT>
struct Base
{
Base()
{ cout << "Base::Base()" << endl; }
~Base()
{ cout << "Base::~Base()" << endl; }
void test(void) const
{
const DerivedT & derivedThis = static_cast<const DerivedT&>(*this);
}
};
template <typename Q>
struct Derived : public Base<Derived<Q> >
{
Derived()
{ cout << "Derived::Derived()" << endl; }
template <typename Q>
Derived(Q )
{ cout << "Derived::Derived(Q)" << endl; }
~Derived()
{ cout << "Derived::~Derived()" << endl; }
};
int main()
{
Derived<void> d;
d.test();
}
-----------------------------------------------------------------------------
MWCW 8.3 output:
Base::Base()
Derived::Derived()
Base::Base()
Derived::Derived(Q)
Base::~Base()
Derived::~Derived()
Base::~Base()
Derived::~Derived()
Base::~Base()
Expected output (double-checked with Comau & MSVC71):
Base::Base()
Derived::Derived()
Derived::~Derived()
Base::~Base()
Joel, you were right, you need a templated copy-ctor to trigger the bug!
Beman, I understand MW has already version 9, but I don't know if it's public
or not. Either way, it wouldn't hurth to Spirit Development if we could get a
copy. If you are in good relation with them, maybe you can praise for this.
We found also other minor bugs, but it takes time to isolate them :) There was
also a bug in the standard library (std::string(iter,iter) constructor) which I
already submitted to the website form, together with a patch to fix it.
Giovanni Bajo
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk