diff --git a/modules/flann/include/opencv2/flann/any.h b/modules/flann/include/opencv2/flann/any.h index 070d5a421f..4042db67c7 100644 --- a/modules/flann/include/opencv2/flann/any.h +++ b/modules/flann/include/opencv2/flann/any.h @@ -257,7 +257,8 @@ public: const T& cast() const { if (policy->type() != typeid(T)) throw anyimpl::bad_any_cast(); - T* r = reinterpret_cast(policy->get_value(const_cast(&object))); + void* obj = const_cast(object); + T* r = reinterpret_cast(policy->get_value(&obj)); return *r; }