From b60d6b7f554a7e2102f89258a1235358945b2b9c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Del=20Pino?= <stephane.delpino44@gmail.com>
Date: Thu, 1 Apr 2021 12:52:11 +0200
Subject: [PATCH] Change constructor in copy function

The previous implementation would allocate an array that would be
destroyed immediately, since the (deep)copy of the array allocates it
properly.
---
 src/mesh/ItemValue.hpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/mesh/ItemValue.hpp b/src/mesh/ItemValue.hpp
index 5115166b8..d39421c5c 100644
--- a/src/mesh/ItemValue.hpp
+++ b/src/mesh/ItemValue.hpp
@@ -37,16 +37,17 @@ class ItemValue
   // Allow const std:weak_ptr version to access our data
   friend ItemValue<std::add_const_t<DataType>, item_type, ConnectivityWeakPtr>;
 
+ public:
   friend PUGS_INLINE ItemValue<std::remove_const_t<DataType>, item_type, ConnectivityPtr>
   copy(const ItemValue<DataType, item_type, ConnectivityPtr>& source)
   {
-    ItemValue<std::remove_const_t<DataType>, item_type, ConnectivityPtr> image(*source.connectivity_ptr());
+    ItemValue<std::remove_const_t<DataType>, item_type, ConnectivityPtr> image;
 
-    image.m_values = copy(source.m_values);
+    image.m_connectivity_ptr = source.m_connectivity_ptr;
+    image.m_values           = copy(source.m_values);
     return image;
   }
 
- public:
   PUGS_INLINE
   bool
   isBuilt() const noexcept
-- 
GitLab