Skip to content

Commit

Permalink
Compile warning from -Wstringop-overread
Browse files Browse the repository at this point in the history
ncmpio_filetype.c: In function 'type_create_subarray64.constprop':
ncmpio_filetype.c:154:21: warning: 'MPI_Type_create_subarray' reading 4 bytes from a region of size 0 [-Wstringop-overread]
154 |         mpireturn = MPI_Type_create_subarray(ndims, sizes, subsizes, starts,
    |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
155 |                                              order, oldtype, newtype);
    |                                              ~~~~~~~~~~~~~~~~~~~~~~~~
ncmpio_filetype.c:154:21: note: referencing argument 3 of type 'const int *'
ncmpio_filetype.c:154:21: warning: 'MPI_Type_create_subarray' reading 4 bytes from a region of size 0 [-Wstringop-overread]
ncmpio_filetype.c:154:21: note: referencing argument 4 of type 'const int *'
In file included from ncmpio_filetype.c:18:
/opt/cray/pe/mpich/8.1.25/ofi/gnu/9.1/include/mpi.h:1362:5: note: in a call to function 'MPI_Type_create_subarray'
1362 | int MPI_Type_create_subarray(int ndims, const int array_of_sizes[],
     |     ^~~~~~~~~~~~~~~~~~~~~~~~
  • Loading branch information
wkliao committed Sep 5, 2023
1 parent 2e85789 commit 2dc59b4
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/drivers/ncmpio/ncmpio_filetype.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,10 @@ type_create_subarray64(int ndims,
}

if (tag == 0) {
int gsizes[24], *sizes, *subsizes, *starts;
int *sizes, *subsizes, *starts;
/* none of dimensions > 2^31-1, we can safely use
* MPI_Type_create_subarray */
if (ndims <= 8) /* avoid malloc */
sizes = gsizes;
else
sizes = (int*) NCI_Malloc((size_t)ndims * 3 * SIZEOF_INT);
sizes = (int*) NCI_Malloc((size_t)ndims * 3 * SIZEOF_INT);
subsizes = sizes + ndims;
starts = subsizes + ndims;
for (i=0; i<ndims; i++) {
Expand All @@ -156,7 +153,7 @@ type_create_subarray64(int ndims,
if (mpireturn != MPI_SUCCESS)
err = ncmpii_error_mpi2nc(mpireturn, "MPI_Type_create_subarray");

if (ndims > 8) NCI_Free(sizes);
NCI_Free(sizes);
return err;
}

Expand Down

0 comments on commit 2dc59b4

Please sign in to comment.