From f128f1b6db765f58256c24926f0219e2b3d1d10f Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Tue, 29 Jun 2021 15:49:33 -0700 Subject: [PATCH] Converting C assert to pybind11_fail (to play safe). --- include/pybind11/detail/smart_holder_type_casters.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/pybind11/detail/smart_holder_type_casters.h b/include/pybind11/detail/smart_holder_type_casters.h index 78e015c93..0aaa4652a 100644 --- a/include/pybind11/detail/smart_holder_type_casters.h +++ b/include/pybind11/detail/smart_holder_type_casters.h @@ -18,7 +18,6 @@ #include "type_caster_base.h" #include "typeid.h" -#include #include #include #include @@ -419,8 +418,10 @@ struct smart_holder_type_caster_load { if (sptsls_ptr != nullptr) { // This code is reachable only if there are multiple registered_instances for the // same pointee. - assert(reinterpret_cast(load_impl.loaded_v_h.inst) - != sptsls_ptr->self); + if (reinterpret_cast(load_impl.loaded_v_h.inst) == sptsls_ptr->self) { + pybind11_fail("smart_holder_type_casters loaded_as_shared_ptr failure: " + "load_impl.loaded_v_h.inst == sptsls_ptr->self"); + } return std::shared_ptr( type_raw_ptr, shared_ptr_trampoline_self_life_support(load_impl.loaded_v_h.inst));