You might be right. intptr_t is a signed type, which allows the result
of % to be potentially negative. However, on the other side, mod is
defined as a size_t which [based on my memory] is definitively
unsigned as it represent a size.

Did you try to apply your patch to Open MPI ? If yes does it resolve
the issue ?