diff --git a/mfbt/NotNull.h b/mfbt/NotNull.h index 0c3c333e4a337..af2e31237e4f2 100644 --- a/mfbt/NotNull.h +++ b/mfbt/NotNull.h @@ -63,6 +63,7 @@ // for the last one, where the handle type is |void|. See below. #include "mozilla/Assertions.h" +#include namespace mozilla { @@ -114,7 +115,12 @@ class NotNull // Construct/assign from another NotNull with a compatible base pointer type. template - MOZ_IMPLICIT NotNull(const NotNull& aOther) : mBasePtr(aOther.get()) {} + MOZ_IMPLICIT NotNull(const NotNull& aOther) : mBasePtr(aOther.get()) { + static_assert(sizeof(T) == sizeof(NotNull), + "NotNull must have zero space overhead."); + static_assert(offsetof(NotNull, mBasePtr) == 0, + "mBasePtr must have zero offset."); + } // Default copy/move construction and assignment. NotNull(const NotNull&) = default;