Commit a5aa7920 authored by Pavan Balaji's avatar Pavan Balaji
Browse files

Fix assertion for large counts.

We were checking for (size of datatype < MPIR_COUNT_MAX / count)
earlier.  This is not a good test when the count is very large.  This
patch modifies the assertion to (count * size of datatype <
MPIR_COUNT_MAX) so we don't run into integer division issues.
Signed-off-by: Rob Latham's avatarRob Latham <>
parent fda1c8ce
......@@ -38,7 +38,7 @@ int MPIR_Status_set_elements_x_impl(MPI_Status *status, MPI_Datatype datatype, M
/* overflow check, should probably be a real error check? */
if (count != 0) {
MPIU_Assert(size_x >= 0 && count > 0);
MPIU_Assert(size_x < MPIR_COUNT_MAX / count);
MPIU_Assert(count * size_x < MPIR_COUNT_MAX);
MPIR_STATUS_SET_COUNT(*status, size_x * count);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment