You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by GitBox <gi...@apache.org> on 2021/03/06 00:31:52 UTC

[GitHub] [trafficserver] ywkaras commented on a change in pull request #7582: Add pointer/reference upcast function that is checked in debug builds.

ywkaras commented on a change in pull request #7582:
URL: https://github.com/apache/trafficserver/pull/7582#discussion_r588798052



##########
File path: include/tscore/ink_assert.h
##########
@@ -53,13 +53,50 @@ inkcoreapi void _ink_assert(const char *a, const char *f, int l) TS_NORETURN;
 
 #ifdef __cplusplus
 }
-#endif /* __cplusplus */
 
-/* workaround a bug in the  stupid Sun preprocessor
+/*
+Use dbg_dyn_cast() to do pointer/reference dynamic upcasts with checked dynamic_cast in debug builds, and with
+static_cast in release (optimized) builds.  Use examples:
+
+class A { public: virtual ~A(); };
+class B : public A {};
+B * foo(A *a) { return dbg_dyn_cast<B>(a); }
+B & foo2(A &a) { return dbg_dyn_cast<B>(a); }
+B const & foo3(A const &a) { return dbg_dyn_cast<B const>(a); }
 
-#undef assert
-#define assert __DONT_USE_BARE_assert_USE_ink_assert__
-#define _ASSERT_H
-#undef __ASSERT_H__
-#define __ASSERT_H__

Review comment:
       Deleted these kruft comments while I was in here.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org