Verified Commit 9e079476 authored by Tyson Smith's avatar Tyson Smith Committed by ma1
Browse files

Bug 2035963 - Add MOZ_EMPTY_BASES to Maybe<T> to fix UBSan on Windows. r=sergesanspaille

Without __declspec(empty_bases), the MSVC ABI doesn't apply empty base
optimization for multiple inheritance. Maybe<T>'s empty base
(Maybe_CopyMove_Enabler<T>) gets a unique 1-byte slot past the storage, and
UBSan fires "insufficient space" when operator= adjusts `this` to that subobject.

Differential Revision: https://phabricator.services.mozilla.com/D299791
parent 67f1d5da
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -360,8 +360,8 @@ constexpr Maybe<U> Some(T&& aValue);
 *     functions |Some()| and |Nothing()|.
 */
template <class T>
class MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS MOZ_GSL_OWNER Maybe
    : private detail::MaybeStorage<T>,
class MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS MOZ_GSL_OWNER
    MOZ_EMPTY_BASES Maybe : private detail::MaybeStorage<T>,
                            public detail::Maybe_CopyMove_Enabler<T> {
  template <typename, bool, bool, bool>
  friend class detail::Maybe_CopyMove_Enabler;