From: Timo Heister Date: Mon, 27 Jul 2015 15:36:16 +0000 (-0400) Subject: avoid dereferencing empty std::vectors X-Git-Tag: v8.4.0-rc2~706^2~4 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=448b2821fffaa33bd0b2f036dee9f2a42d66a160;p=dealii.git avoid dereferencing empty std::vectors --- diff --git a/include/deal.II/lac/parallel_vector.templates.h b/include/deal.II/lac/parallel_vector.templates.h index 0230a8e926..89b280dfc9 100644 --- a/include/deal.II/lac/parallel_vector.templates.h +++ b/include/deal.II/lac/parallel_vector.templates.h @@ -633,19 +633,25 @@ namespace parallel // make sure that there are not outstanding requests from updating // ghost values or compress int flag = 1; - int ierr = MPI_Testall (update_ghost_values_requests.size(), - &update_ghost_values_requests[0], - &flag, MPI_STATUSES_IGNORE); - Assert (ierr == MPI_SUCCESS, ExcInternalError()); - Assert (flag == 1, - ExcMessage("MPI found unfinished update_ghost_values() requests" - "when calling swap, which is not allowed")); - ierr = MPI_Testall (compress_requests.size(), &compress_requests[0], - &flag, MPI_STATUSES_IGNORE); - Assert (ierr == MPI_SUCCESS, ExcInternalError()); - Assert (flag == 1, - ExcMessage("MPI found unfinished compress() requests " - "when calling swap, which is not allowed")); + if (update_ghost_values_requests.size()>0) + { + int ierr = MPI_Testall (update_ghost_values_requests.size(), + &update_ghost_values_requests[0], + &flag, MPI_STATUSES_IGNORE); + Assert (ierr == MPI_SUCCESS, ExcInternalError()); + Assert (flag == 1, + ExcMessage("MPI found unfinished update_ghost_values() requests" + "when calling swap, which is not allowed")); + } + if (compress_requests.size()>0) + { + int ierr = MPI_Testall (compress_requests.size(), &compress_requests[0], + &flag, MPI_STATUSES_IGNORE); + Assert (ierr == MPI_SUCCESS, ExcInternalError()); + Assert (flag == 1, + ExcMessage("MPI found unfinished compress() requests " + "when calling swap, which is not allowed")); + } } #endif diff --git a/source/base/partitioner.cc b/source/base/partitioner.cc index 39240e1e4e..1b216a9d4e 100644 --- a/source/base/partitioner.cc +++ b/source/base/partitioner.cc @@ -281,8 +281,9 @@ namespace Utilities } AssertDimension (current_index_start, n_ghost_indices_data); - MPI_Waitall (import_requests.size(), &import_requests[0], - MPI_STATUSES_IGNORE); + if (import_requests.size()>0) + MPI_Waitall (import_requests.size(), &import_requests[0], + MPI_STATUSES_IGNORE); // transform import indices to local index space and compress // contiguous indices in form of ranges