Skip to content

Commit

Permalink
Merge pull request #13448 from bangerth/assertion
Browse files Browse the repository at this point in the history
Add an assertion for p4est weights.
  • Loading branch information
marcfehling committed Feb 26, 2022
2 parents 99d9108 + b0e863e commit 02034da
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions source/distributed/tria.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 static_cast<int>(weight);
}

template <int dim, int spacedim>
Expand Down

0 comments on commit 02034da

Please sign in to comment.