]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add an assertion for p4est weights.
authorWolfgang Bangerth <bangerth@colostate.edu>
Fri, 25 Feb 2022 18:14:59 +0000 (11:14 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Fri, 25 Feb 2022 18:14:59 +0000 (11:14 -0700)
source/distributed/tria.cc

index 051ea1540a48f2efda6b3cba4b90b8eb0cc18aea..af2cf7c3803a543eabf30af8524ce77354387d81 100644 (file)
@@ -1508,8 +1508,17 @@ namespace
     Assert(this_object->current_pointer < this_object->cell_weights_list.end(),
            ExcInternalError());
 
-    // get the weight, increment the pointer, and return the weight
-    return *this_object->current_pointer++;
+    // Get the weight, increment the pointer, and return the weight. Also
+    // make sure that we don't exceed the 'int' data type that p4est uses
+    // to represent weights
+    const unsigned int weight = *this_object->current_pointer;
+    ++this_object->current_pointer;
+
+    Assert(weight < std::numeric_limits<int>::max(),
+           ExcMessage("p4est uses 'signed int' to represent the partition "
+                      "weights for cells. The weight provided here exceeds "
+                      "the maximum value represented as a 'signed int'."));
+    return weight;
   }
 
   template <int dim, int spacedim>

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.