diff options
author | Roland Haas <roland.haas@physics.gatech.edu> | 2012-05-29 10:19:53 -0700 |
---|---|---|
committer | Roland Haas <roland.haas@physics.gatech.edu> | 2012-05-29 10:19:53 -0700 |
commit | c79611aa3ee3d5782a7e2c42e0895dbf50cce355 (patch) | |
tree | 98025853ec8c20f50d7102d9df7545f40bfc2b20 | |
parent | a499fb9529164f6c9193abe00f5191f9c6cf6dc5 (diff) |
CarpetLib: add self-copy logic to classes with pointer members
right now disabled by an assert
-rw-r--r-- | Carpet/CarpetLib/src/bintree.cc | 3 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/fulltree.cc | 3 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/prolongate_3d_real8_eno.F90 | 2 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/region.cc | 3 |
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; |