diff --git a/OgreMain/include/OgreSingleton.h b/OgreMain/include/OgreSingleton.h index be07e9c1198..66323a15b1b 100644 --- a/OgreMain/include/OgreSingleton.h +++ b/OgreMain/include/OgreSingleton.h @@ -80,6 +80,14 @@ template class Singleton static T* msSingleton; public: +#if defined(__has_attribute) +# if __has_attribute(no_sanitize) + // The `static_cast` happens so early in the construction of the inheriting + // classes that the `this` pointer is still detected as the super class + // pointer. Therefore, disabling vptr checks. + __attribute__((no_sanitize("vptr"))) +# endif +#endif Singleton(void) { OgreAssert(!msSingleton, "There can be only one singleton");