]> https://gitweb.dealii.org/ - dealii.git/commitdiff
avoid dereferencing empty std::vectors
authorTimo Heister <timo.heister@gmail.com>
Mon, 27 Jul 2015 15:36:16 +0000 (11:36 -0400)
committerTimo Heister <timo.heister@gmail.com>
Mon, 27 Jul 2015 15:36:16 +0000 (11:36 -0400)
include/deal.II/lac/parallel_vector.templates.h
source/base/partitioner.cc

index 0230a8e926de95fbb1424c0f67a4c1df772bc87d..89b280dfc9cf2ce895f8fb230a45eb13d6a013e5 100644 (file)
@@ -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
 
index 39240e1e4e541785abbb9a670f0e5e5d1ef21080..1b216a9d4ef1de6eafe59c98ef30b411513a0293 100644 (file)
@@ -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

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.