From: Matthias Maier Date: Mon, 4 May 2015 08:25:47 +0000 (+0200) Subject: Bugfix: Correctly set up object in move constructor X-Git-Tag: v8.3.0-rc1~202^2~5 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a471a53c6623b5a5bc9c455c96d3e9cc65c7546c;p=dealii.git Bugfix: Correctly set up object in move constructor --- diff --git a/include/deal.II/lac/petsc_parallel_vector.h b/include/deal.II/lac/petsc_parallel_vector.h index e8ddd6b31b..ea6137f65d 100644 --- a/include/deal.II/lac/petsc_parallel_vector.h +++ b/include/deal.II/lac/petsc_parallel_vector.h @@ -188,7 +188,7 @@ namespace PETScWrappers #ifdef DEAL_II_WITH_CXX11 // explicitly declare default variant, such that below move constructor // does not dissallow it - Vector (const Vector &v) = default; + Vector (const Vector &) = default; /** * Move constructor. Creates a new vector by stealing the internal data diff --git a/source/lac/petsc_parallel_vector.cc b/source/lac/petsc_parallel_vector.cc index 898b98e23c..c6d0749f31 100644 --- a/source/lac/petsc_parallel_vector.cc +++ b/source/lac/petsc_parallel_vector.cc @@ -30,10 +30,8 @@ namespace PETScWrappers Vector::Vector () { - // this is an invalid empty vector, so we - // can just as well create a sequential - // one to avoid all the overhead incurred - // by parallelism + // this is an invalid empty vector, so we can just as well create a + // sequential one to avoid all the overhead incurred by parallelism const int n = 0; const int ierr = VecCreateSeq (PETSC_COMM_SELF, n, &vector); @@ -46,6 +44,14 @@ namespace PETScWrappers #ifdef DEAL_II_WITH_CXX11 Vector::Vector (Vector &&v) { + // this is an invalid empty vector, so we can just as well create a + // sequential one to avoid all the overhead incurred by parallelism + const int n = 0; + const int ierr + = VecCreateSeq (PETSC_COMM_SELF, n, &vector); + AssertThrow (ierr == 0, ExcPETScError(ierr)); + ghosted = false; + swap(v); } #endif