/* Gather all colors and keys on rank 0 */
const std::array<int, 2> sendbuf = {{color, key}};
std::vector<int> recvbuf;
- if (myrank == 0)
+ int* recvbuf_ptr;
+ if (myrank == 0) {
recvbuf.resize(2 * size);
- gather__default(sendbuf.data(), 2, MPI_INT, recvbuf.data(), 2, MPI_INT, 0, this);
+ recvbuf_ptr = recvbuf.data();
+ } else {
+ recvbuf_ptr = nullptr;
+ }
+ gather__default(sendbuf.data(), 2, MPI_INT, recvbuf_ptr, 2, MPI_INT, 0, this);
/* Do the actual job */
if (myrank == 0) {
std::vector<MPI_Group> group_snd(size);