xref: /llvm-project/clang-tools-extra/docs/clang-tidy/checks/mpi/buffer-deref.rst (revision 6e566bc5523f743bc34a7e26f050f1f2b4d699a8)
1*6e566bc5SRichard.. title:: clang-tidy - mpi-buffer-deref
2*6e566bc5SRichard
3*6e566bc5SRichardmpi-buffer-deref
4*6e566bc5SRichard================
5*6e566bc5SRichard
6*6e566bc5SRichardThis check verifies if a buffer passed to an MPI (Message Passing Interface)
7*6e566bc5SRichardfunction is sufficiently dereferenced. Buffers should be passed as a single
8*6e566bc5SRichardpointer or array. As MPI function signatures specify ``void *`` for their buffer
9*6e566bc5SRichardtypes, insufficiently dereferenced buffers can be passed, like for example as
10*6e566bc5SRicharddouble pointers or multidimensional arrays, without a compiler warning emitted.
11*6e566bc5SRichard
12*6e566bc5SRichardExamples:
13*6e566bc5SRichard
14*6e566bc5SRichard.. code-block:: c++
15*6e566bc5SRichard
16*6e566bc5SRichard   // A double pointer is passed to the MPI function.
17*6e566bc5SRichard   char *buf;
18*6e566bc5SRichard   MPI_Send(&buf, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
19*6e566bc5SRichard
20*6e566bc5SRichard   // A multidimensional array is passed to the MPI function.
21*6e566bc5SRichard   short buf[1][1];
22*6e566bc5SRichard   MPI_Send(buf, 1, MPI_SHORT, 0, 0, MPI_COMM_WORLD);
23*6e566bc5SRichard
24*6e566bc5SRichard   // A pointer to an array is passed to the MPI function.
25*6e566bc5SRichard   short *buf[1];
26*6e566bc5SRichard   MPI_Send(buf, 1, MPI_SHORT, 0, 0, MPI_COMM_WORLD);
27