<div dir="ltr">Dear Clang developers,<br>  We met a problem in MPI type tag checking for MPI_2INT. In MPICH, we use this Clang extension as follows:<br>  <br><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
#define MPI_2INT                           ((MPI_Datatype)0x4c000816<br>struct mpich_struct_mpi_2int            { int i1; int i2; };<br>static const MPI_Datatype mpich_mpi_2int            MPICH_ATTR_TYPE_TAG_LAYOUT_COMPATIBLE(struct mpich_struct_mpi_2int)            = MPI_2INT;<br>
int MPI_Send(const void *buf, int count, MPI_Datatype datatype, int dest, int tag,<br>             MPI_Comm comm) MPICH_ATTR_POINTER_WITH_TYPE_TAG(1,3) MPICH_ATTR_WEAK_ALIAS("PMPI_Send");</blockquote><br>In a program, we have such code and it works fine.<br>
<br><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">struct {int value; int loc; } in;<br>MPI_Send(&in, 1, MPI_2INT,...);</blockquote><br>But if we write it in other ways, there are warnings.<br><br>
<blockquote style="margin:0 0 0 40px;border:none;padding:0px">int in[2];<br>MPI_Send(in, 1, MPI_2INT,...); // warning: argument type 'int *' doesn't match specified 'MPI' type tag [-Wtype-safety]</blockquote>
OR<br><blockquote style="margin:0 0 0 40px;border:none;padding:0px">typedef int intpair[2];<br>intpair in;<br>MPI_Send(&in, 1, MPI_2INT, ...); // warning: argument type 'intpair *' (aka 'int (*)[2]') doesn't match specified 'MPI' type tag [-Wtype-safety]</blockquote>
<br>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?<div><div><br></div><div>Thanks<br>--Junchao Zhang<br><div><div>

</div>
</div></div></div></div>