diff options
author | Roland Haas <roland.haas@physics.gatech.edu> | 2012-05-29 10:19:53 -0700 |
---|---|---|
committer | Barry Wardell <barry.wardell@gmail.com> | 2012-09-11 18:23:31 +0100 |
commit | 64f8068bb77c589566836b5ebb7cd719fa883c29 (patch) | |
tree | f27e3dfdd56af554c4624e2987e6091b330123b5 | |
parent | 3af3dfa78c78075b962b639fcd93cb2714a0f825 (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; |