From 014e6bcbde7764a3d72bf448ea460be43435dcfc Mon Sep 17 00:00:00 2001 From: Sungun Park Date: Thu, 10 Oct 2024 10:12:22 -0700 Subject: [PATCH] Update hardware Handle (#8187) In certain compilers, the assignment operators defined as default doesn't automatically make a call to the parent's method if it's user-defined. Make this behavior explicit to avoid this edge case. BUGS=[371980551] --- filament/backend/include/backend/Handle.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/filament/backend/include/backend/Handle.h b/filament/backend/include/backend/Handle.h index 2cf52244149..d5e88206b8f 100644 --- a/filament/backend/include/backend/Handle.h +++ b/filament/backend/include/backend/Handle.h @@ -23,6 +23,7 @@ #include #include // FIXME: STL headers are not allowed in public headers +#include #include @@ -106,8 +107,18 @@ struct Handle : public HandleBase { Handle(Handle const& rhs) noexcept = default; Handle(Handle&& rhs) noexcept = default; - Handle& operator=(Handle const& rhs) noexcept = default; - Handle& operator=(Handle&& rhs) noexcept = default; + // Explicitly redefine copy/move assignment operators rather than just using default here. + // Because it doesn't make a call to the parent's method automatically during the std::move + // function call(https://en.cppreference.com/w/cpp/algorithm/move) in certain compilers like + // NDK 25.1.8937393 and below (see b/371980551) + Handle& operator=(Handle const& rhs) noexcept { + HandleBase::operator=(rhs); + return *this; + } + Handle& operator=(Handle&& rhs) noexcept { + HandleBase::operator=(std::move(rhs)); + return *this; + } explicit Handle(HandleId id) noexcept : HandleBase(id) { }