The oParamPtrVar function has a const T* const&
parameter, and the object it constructs stores a copy
of the reference. When called with a
pointer-to-non-const (such as in tests 6 and 8), type
conversion is needed and a temporary is used. When this
happens, the ParamPtrVar object holds a reference to
the temporary, and not to the original pointer. This
can be problematic because the temporary may go away
before the ParamPtrVar needs to access it.
One way to fix is is to add an overload for
oParamPtrVar so that no conversion is needed for these
cases:
template<class T>
inline Handle<Param> oParamPtrVar(T* const&
ptr_var, const std::string& s)
{
T*& ncptr_var=const_cast<T*&>(ptr_var);
return Handle<Param>(new
ParamPtrVar<T>(ncptr_var,s,false,true,Handle<ValueSource>()));
}