From 54eda5928605cee0f4c9948926ed385164d67bd8 Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Thu, 9 Sep 2021 12:33:50 -0700 Subject: [PATCH] [wpiutil] Ignore ubsan vptr upcast warning in SendableHelper moves (#3553) The move ctor is trying to cast from e.g. SendableHelper to PIDController before PIDController has been constructed, which is potentially UB. We don't actually use anything in PIDController though, so it's OK in our case. --- .../main/native/include/wpi/sendable/SendableHelper.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/wpiutil/src/main/native/include/wpi/sendable/SendableHelper.h b/wpiutil/src/main/native/include/wpi/sendable/SendableHelper.h index c65f2d003b..5b6bbe3dad 100644 --- a/wpiutil/src/main/native/include/wpi/sendable/SendableHelper.h +++ b/wpiutil/src/main/native/include/wpi/sendable/SendableHelper.h @@ -26,13 +26,22 @@ class SendableHelper { SendableHelper(const SendableHelper& rhs) = default; SendableHelper& operator=(const SendableHelper& rhs) = default; +#if !defined(_MSC_VER) && (defined(__llvm__) || __GNUC__ > 7) + // See https://bugzilla.mozilla.org/show_bug.cgi?id=1442819 + __attribute__((no_sanitize("vptr"))) +#endif SendableHelper(SendableHelper&& rhs) { // it is safe to call Move() multiple times with the same rhs SendableRegistry::Move(static_cast(this), static_cast(&rhs)); } - SendableHelper& operator=(SendableHelper&& rhs) { +#if !defined(_MSC_VER) && (defined(__llvm__) || __GNUC__ > 7) + // See https://bugzilla.mozilla.org/show_bug.cgi?id=1442819 + __attribute__((no_sanitize("vptr"))) +#endif + SendableHelper& + operator=(SendableHelper&& rhs) { // it is safe to call Move() multiple times with the same rhs SendableRegistry::Move(static_cast(this), static_cast(&rhs));