diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index 5dda8f7d3..38918ee89 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -204,7 +204,7 @@ public: protected: template ::value, int>::type = 0> static void *copy_constructor(const void *arg) { - return new type(*((const type *) arg)); + return (void *) new type(*((const type *) arg)); } template ::value, int>::type = 0> static void *copy_constructor(const void *) { return nullptr; } @@ -508,7 +508,7 @@ public: return true; } else if (PyType_IsSubtype(Py_TYPE(src.ptr()), typeinfo->type)) { auto inst = (instance *) src.ptr(); - value = inst->value; + value = (void *) inst->value; holder = inst->holder; return true; } diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index c78f1e220..4cf8ead1f 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -864,7 +864,7 @@ private: template static void init_holder_helper(instance_type *inst, const holder_type * /* unused */, const std::enable_shared_from_this * /* dummy */) { try { - new (&inst->holder) holder_type(inst->value->shared_from_this()); + new (&inst->holder) holder_type(std::static_pointer_cast(inst->value->shared_from_this())); } catch (const std::bad_weak_ptr &) { new (&inst->holder) holder_type(inst->value); }