diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_typed_address.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_typed_address.hpp index b50807bb2..7144bf5b4 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_k_typed_address.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_k_typed_address.hpp @@ -32,13 +32,10 @@ namespace ams::kern { constexpr ALWAYS_INLINE explicit KTypedAddress(U *ptr) : address(reinterpret_cast(ptr)) { /* ... */ } /* Copy constructor. */ - constexpr ALWAYS_INLINE KTypedAddress(const KTypedAddress &rhs) : address(rhs.address) { /* ... */ } + constexpr ALWAYS_INLINE KTypedAddress(const KTypedAddress &rhs) = default; /* Assignment operator. */ - constexpr ALWAYS_INLINE KTypedAddress operator=(KTypedAddress rhs) { - this->address = rhs.address; - return *this; - } + constexpr ALWAYS_INLINE KTypedAddress &operator=(const KTypedAddress &rhs) = default; /* Arithmetic operators. */ template @@ -203,6 +200,26 @@ namespace ams::kern { static_assert(sizeof(KVirtualAddress) == sizeof(uintptr_t)); static_assert(sizeof(KProcessAddress) == sizeof(uintptr_t)); + static_assert(std::is_trivially_copyable::value); + static_assert(std::is_trivially_copyable::value); + static_assert(std::is_trivially_copyable::value); + + static_assert(std::is_trivially_copy_constructible::value); + static_assert(std::is_trivially_copy_constructible::value); + static_assert(std::is_trivially_copy_constructible::value); + + static_assert(std::is_trivially_move_constructible::value); + static_assert(std::is_trivially_move_constructible::value); + static_assert(std::is_trivially_move_constructible::value); + + static_assert(std::is_trivially_copy_assignable::value); + static_assert(std::is_trivially_copy_assignable::value); + static_assert(std::is_trivially_copy_assignable::value); + + static_assert(std::is_trivially_move_assignable::value); + static_assert(std::is_trivially_move_assignable::value); + static_assert(std::is_trivially_move_assignable::value); + static_assert(std::is_trivially_destructible::value); static_assert(std::is_trivially_destructible::value); static_assert(std::is_trivially_destructible::value); @@ -212,6 +229,10 @@ namespace ams::kern { static_assert(Null == Null); static_assert(Null == Null); + /* Constructor/assignment validations. */ + static_assert([]{ const KPhysicalAddress a(5); KPhysicalAddress b(a); return b; }() == KPhysicalAddress(5)); + static_assert([]{ const KPhysicalAddress a(5); KPhysicalAddress b(10); b = a; return b; }() == KPhysicalAddress(5)); + /* Arithmetic validations. */ static_assert(KPhysicalAddress(10) + 5 == KPhysicalAddress(15)); static_assert(KPhysicalAddress(10) - 5 == KPhysicalAddress(5));