Type safety checking for MPI_2INT

Dear Clang developers,
We met a problem in MPI type tag checking for MPI_2INT. In MPICH, we use this Clang extension as follows:

#define MPI_2INT ((MPI_Datatype)0x4c000816
struct mpich_struct_mpi_2int { int i1; int i2; };
static const MPI_Datatype mpich_mpi_2int MPICH_ATTR_TYPE_TAG_LAYOUT_COMPATIBLE(struct mpich_struct_mpi_2int) = MPI_2INT;
int MPI_Send(const void *buf, int count, MPI_Datatype datatype, int dest, int tag,

In a program, we have such code and it works fine.

struct {int value; int loc; } in;
MPI_Send(&in, 1, MPI_2INT,…);

But if we write it in other ways, there are warnings.

int in[2];
MPI_Send(in, 1, MPI_2INT,…); // warning: argument type ‘int *’ doesn’t match specified ‘MPI’ type tag [-Wtype-safety]


typedef int intpair[2];
intpair in;
MPI_Send(&in, 1, MPI_2INT, …); // warning: argument type ‘intpair ’ (aka 'int ()[2]’) doesn’t match specified ‘MPI’ type tag [-Wtype-safety]

Since struct {int i1; int i2} is guaranteed to have the same layout as int[2]. It seems Clang has generated erroneous warnings in this case. Is it right?

–Junchao Zhang