From: Wolfgang Bangerth Date: Fri, 25 Feb 2022 18:14:59 +0000 (-0700) Subject: Add an assertion for p4est weights. X-Git-Tag: v9.4.0-rc1~441^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=447abc2b086766464945abad0b33c07cc3ed5821;p=dealii.git Add an assertion for p4est weights. --- diff --git a/source/distributed/tria.cc b/source/distributed/tria.cc index 051ea1540a..af2cf7c380 100644 --- a/source/distributed/tria.cc +++ b/source/distributed/tria.cc @@ -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::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