diff --git a/Src/Base/AMReX_MultiFab.H b/Src/Base/AMReX_MultiFab.H index 6cb4c46e7df..8ec62700cc1 100644 --- a/Src/Base/AMReX_MultiFab.H +++ b/Src/Base/AMReX_MultiFab.H @@ -492,7 +492,7 @@ public: * This uses the same arena and factory in the copy and copies * all data. */ - MultiFab deepCopy (); + [[nodiscard]] MultiFab deepCopy () const; /** * \brief Copy from src to dst including nghost ghost cells. diff --git a/Src/Base/AMReX_MultiFab.cpp b/Src/Base/AMReX_MultiFab.cpp index 41ec0093b62..2a80123836b 100644 --- a/Src/Base/AMReX_MultiFab.cpp +++ b/Src/Base/AMReX_MultiFab.cpp @@ -168,9 +168,9 @@ MultiFab::Add (MultiFab& dst, const MultiFab& src, } MultiFab -MultiFab::deepCopy () +MultiFab::deepCopy () const { - auto mf = MultiFab( + MultiFab mf( this->boxArray(), this->DistributionMap(), this->nComp(),