diff --git a/include/pybind11/detail/type_caster_base.h b/include/pybind11/detail/type_caster_base.h index a708d87f..e2d1bcb8 100644 --- a/include/pybind11/detail/type_caster_base.h +++ b/include/pybind11/detail/type_caster_base.h @@ -927,17 +927,18 @@ protected: using Constructor = void *(*)(const void *); /* Only enabled when the types are {copy,move}-constructible *and* when the type - does not have a private operator new implementation. A comma operator is used in the decltype - argument to apply SFINAE to the public copy/move constructors.*/ + does not have a private operator new implementation. */ template ::value>> - static auto make_copy_constructor(const T *) -> decltype(new T(std::declval()), Constructor{}) { + static auto make_copy_constructor(const T *x) -> decltype(new T(*x), Constructor{}) { + PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(x); return [](const void *arg) -> void * { return new T(*reinterpret_cast(arg)); }; } template ::value>> - static auto make_move_constructor(const T *) -> decltype(new T(std::declval()), Constructor{}) { + static auto make_move_constructor(const T *x) -> decltype(new T(std::move(*const_cast(x))), Constructor{}) { + PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(x); return [](const void *arg) -> void * { return new T(std::move(*const_cast(reinterpret_cast(arg)))); };