The following test case reproduces the bug:
*****************************************************
template <class T>
struct Base
{
int i;
};
template <class T>
struct Base_0 : virtual Base<T>
{
public:
T a; // non-empty body
Base_0();
};
template <class T>
struct Derived : public Base_0<T>
{
public:
T b; // non-empty body
Derived();
};
template <class T>
class my_ptr
{
public:
T* _ptr;
my_ptr();
template <class U>
my_ptr(U *rhs) : _ptr (rhs) { }
template <class U>
my_ptr(const my_ptr<U> &rhs) : _ptr (rhs._ptr) { }
};
Derived<int>* const pDer = new Derived<int>;
my_ptr<volatile Derived<int> > ptr_0 (pDer);
my_ptr<volatile Base_0<int> > ptr_1 (ptr_0);
********************************************************
aCC -V t2.cpp
aCC: HP ANSI C++ B3910B A.03.73
Error 440: "t2.cpp", line 34 # Cannot initialize 'volatile Base_0<int>
*' with 'volatile Derived<int> *const'.
my_ptr(const my_ptr<U> &rhs) : _ptr (rhs._ptr) { }
^^^^^^^^
Error 445: "t2.cpp", line 1 # Cannot recover from earlier errors.
template <class T>
^^^^^^^^^^^^^^^^^^
********************************************************
It seems to me that
>Derived<int>* const pDer = new Derived<int>;
>my_ptr<volatile Derived<int> > ptr_0 (pDer);
>my_ptr<volatile Base_0<int> > ptr_1 (ptr_0);
Is essentially performing the following which doesn't cause the compiler
error to occur:
>Derived<int>* const pDer = new Derived<int>;
>volatile Derived<int> *ptr_0 = pDer;
>volatile Base_0<int> *ptr_1 = ptr_0;