This is an automated email from the ASF dual-hosted git repository. wangdan pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-pegasus.git
The following commit(s) were added to refs/heads/master by this push: new c6cf82b49 fix: use RTTI to do double-check for `down_cast` only in debug mode (#2260) c6cf82b49 is described below commit c6cf82b493962e6ffd60b2b3a83fce5e152c0c82 Author: Dan Wang <wang...@apache.org> AuthorDate: Mon Jun 16 12:12:02 2025 +0800 fix: use RTTI to do double-check for `down_cast` only in debug mode (#2260) --- src/utils/casts.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/utils/casts.h b/src/utils/casts.h index ce20a7770..86aaabf43 100644 --- a/src/utils/casts.h +++ b/src/utils/casts.h @@ -17,9 +17,10 @@ #pragma once -#include <cassert> #include <type_traits> +#include "utils/fmt_logging.h" + namespace dsn { // Downcasting is to convert a base-class pointer(reference) to a derived-class @@ -36,10 +37,8 @@ inline To down_cast(From *from) typename std::remove_pointer<To>::type>::value, "<To> class is not derived from <From> class"); - // Use RTTI to do double-check, though in practice the unit tests are seldom built in debug - // mode. For example, the unit tests of github CI for both rDSN and Pegasus are built in - // release mode. - CHECK(from == NULL || dynamic_cast<To>(from) != NULL, ""); + // Use RTTI to do double-check only in debug mode. + DCHECK(from == NULL || dynamic_cast<To>(from) != NULL, ""); return static_cast<To>(from); } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pegasus.apache.org For additional commands, e-mail: commits-h...@pegasus.apache.org