[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.
This commit is contained in:
Tyler Veness
2021-09-09 12:33:50 -07:00
committed by GitHub
parent 5a4f75c9f8
commit 54eda59286

View File

@@ -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<Derived*>(this),
static_cast<Derived*>(&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<Derived*>(this),
static_cast<Derived*>(&rhs));