aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland Haas <roland.haas@physics.gatech.edu>2012-05-29 10:19:53 -0700
committerRoland Haas <roland.haas@physics.gatech.edu>2012-05-29 10:19:53 -0700
commitc79611aa3ee3d5782a7e2c42e0895dbf50cce355 (patch)
tree98025853ec8c20f50d7102d9df7545f40bfc2b20
parenta499fb9529164f6c9193abe00f5191f9c6cf6dc5 (diff)
CarpetLib: add self-copy logic to classes with pointer members
right now disabled by an assert
-rw-r--r--Carpet/CarpetLib/src/bintree.cc3
-rw-r--r--Carpet/CarpetLib/src/fulltree.cc3
-rw-r--r--Carpet/CarpetLib/src/prolongate_3d_real8_eno.F902
-rw-r--r--Carpet/CarpetLib/src/region.cc3
4 files changed, 10 insertions, 1 deletions
diff --git a/Carpet/CarpetLib/src/bintree.cc b/Carpet/CarpetLib/src/bintree.cc
index db3b27e1c..59c1e0a84 100644
--- a/Carpet/CarpetLib/src/bintree.cc
+++ b/Carpet/CarpetLib/src/bintree.cc
@@ -75,6 +75,9 @@ template <typename T, int D, typename P>
bintree<T,D,P> &
bintree<T,D,P>::operator= (bintree const & t)
{
+ assert (&t != this); // subtree delet handling is currently incorrect in this case
+ if (&t == this) return *this; // nothing to do
+
assert (invariant());
if (is_branch()) {
for (int i=0; i<2; ++i) {
diff --git a/Carpet/CarpetLib/src/fulltree.cc b/Carpet/CarpetLib/src/fulltree.cc
index d482691cf..202d59b77 100644
--- a/Carpet/CarpetLib/src/fulltree.cc
+++ b/Carpet/CarpetLib/src/fulltree.cc
@@ -77,6 +77,9 @@ template <typename T, int D, typename P>
fulltree<T,D,P> &
fulltree<T,D,P>::operator= (fulltree const & t)
{
+ assert (&t != this); // subtree delet handling is currently incorrect in this case
+ if (&t == this) return *this; // nothing to do
+
assert (invariant());
if (is_branch()) {
for (size_t i=0; i<subtrees.size(); ++i) {
diff --git a/Carpet/CarpetLib/src/prolongate_3d_real8_eno.F90 b/Carpet/CarpetLib/src/prolongate_3d_real8_eno.F90
index d803ec2e6..fbff861c4 100644
--- a/Carpet/CarpetLib/src/prolongate_3d_real8_eno.F90
+++ b/Carpet/CarpetLib/src/prolongate_3d_real8_eno.F90
@@ -25,7 +25,7 @@ function eno1d(q)
implicit none
CCTK_REAL8 :: eno1d
- CCTK_REAL8 :: q(4)
+ CCTK_REAL8, INTENT(IN) :: q(4)
CCTK_REAL8 :: zero, one, two, three, six, half, eighth
parameter (zero = 0)
parameter (two = 2)
diff --git a/Carpet/CarpetLib/src/region.cc b/Carpet/CarpetLib/src/region.cc
index ea8572b1f..a709364dd 100644
--- a/Carpet/CarpetLib/src/region.cc
+++ b/Carpet/CarpetLib/src/region.cc
@@ -35,6 +35,9 @@ region_t::region_t (region_t const & a)
region_t &
region_t::operator= (region_t const & a)
{
+ assert(&a != this); // was not correctly handled before, see if it was actually used
+ if (&a == this) return *this; // nothing to do
+
assert (invariant());
if (processors != NULL) {
delete processors;