From 2dc59b445eaa33e9d64ce4f483fe625b8b235fd6 Mon Sep 17 00:00:00 2001 From: Wei-keng Liao Date: Tue, 5 Sep 2023 12:22:24 -0700 Subject: [PATCH] Compile warning from -Wstringop-overread 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[], | ^~~~~~~~~~~~~~~~~~~~~~~~ --- src/drivers/ncmpio/ncmpio_filetype.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/drivers/ncmpio/ncmpio_filetype.c b/src/drivers/ncmpio/ncmpio_filetype.c index c04190e5a..b46d9a6ba 100644 --- a/src/drivers/ncmpio/ncmpio_filetype.c +++ b/src/drivers/ncmpio/ncmpio_filetype.c @@ -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 8) NCI_Free(sizes); + NCI_Free(sizes); return err; }