From a471a53c6623b5a5bc9c455c96d3e9cc65c7546c Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Mon, 4 May 2015 10:25:47 +0200 Subject: [PATCH] Bugfix: Correctly set up object in move constructor --- include/deal.II/lac/petsc_parallel_vector.h | 2 +- source/lac/petsc_parallel_vector.cc | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) 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 -- 2.39.5