From ecb1f206f7dd50d510e2ec082a51a338bb86c4c3 Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Thu, 2 Aug 2018 12:08:07 +0200 Subject: [PATCH] Fix dangling reference as cell returns a copy of geometry now. When geometry() returned a reference we could simply store a reference to its stored center. With the geometry returned as a copy this has become a dangling reference. We fix this by storing a constant reference to the geometry and then reference its center. --- opm/upscaling/RelPermUtils.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/opm/upscaling/RelPermUtils.cpp b/opm/upscaling/RelPermUtils.cpp index 600f1905..48d88703 100644 --- a/opm/upscaling/RelPermUtils.cpp +++ b/opm/upscaling/RelPermUtils.cpp @@ -701,7 +701,8 @@ void RelPermUpscaleHelper::calculateCellPressureGradients() grid.getIJK(ix, ijk); mt.activateCell(ijk); - const auto& cc = c->geometry().center(); + const auto & geom = c->geometry(); //geometry() returns a copy that now lives on. + const auto & cc = geom.center(); celldepth[ix] = cc[ cc.size() - 1 ]; } }