From 92ba286ea5cfeb6d3973515f0eb4b23747097c50 Mon Sep 17 00:00:00 2001 From: Wei-keng Liao Date: Tue, 5 Sep 2023 12:24:47 -0700 Subject: [PATCH] icc complains conversion from 'long long' to 'float' when -Wimplicit-const-int-float-conversion is used. ncx.c:2824:12: warning: implicit conversion from 'long long' to 'float' changes value from 9223372036854775807 to 9223372036854775808 [-Wimplicit-const-int-float-conversion] if (xx == LONGLONG_MAX) *ip = LONGLONG_MAX; ~~ ^~~~~~~~~~~~ ncx.c:64:22: note: expanded from macro 'LONGLONG_MAX' #define LONGLONG_MAX LONG_LONG_MAX ^~~~~~~~~~~~~ ncx.c:61:23: note: expanded from macro 'LONG_LONG_MAX' #define LONG_LONG_MAX LLONG_MAX ^~~~~~~~~ /opt/intel/oneapi/compiler/2023.1.0/linux/lib/clang/16/include/limits.h:103:20: note: expanded from macro 'LLONG_MAX' #define LLONG_MAX __LONG_LONG_MAX__ ^~~~~~~~~~~~~~~~~ :52:27: note: expanded from here #define __LONG_LONG_MAX__ 9223372036854775807LL ^~~~~~~~~~~~~~~~~~~~~ --- src/drivers/common/ncx.m4 | 26 +++++++++++++------------- src/utils/ncmpidump/ncmpidump.c | 4 ++-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/drivers/common/ncx.m4 b/src/drivers/common/ncx.m4 index 3ea3ec2fa..62871970a 100644 --- a/src/drivers/common/ncx.m4 +++ b/src/drivers/common/ncx.m4 @@ -513,18 +513,18 @@ define(`GETF_CheckBND', ')dnl dnl -dnl For GET APIs boudnary check for when $1 is either 'longlong' or 'ulonglong' +dnl For GET APIs boudnary check for when $2 is either 'longlong' or 'ulonglong' dnl define(`GETF_CheckBND2', - `ifelse(index(`$1',`u'), 0, -`if (xx == Upcase($1)_MAX) *ip = Upcase($1)_MAX;',dnl for unsigned type -`if (xx == Upcase($1)_MAX) *ip = Upcase($1)_MAX; - else if (xx == Upcase($1)_MIN) *ip = Upcase($1)_MIN;') - else if (xx > (double)Upcase($1)_MAX || xx < Dmin($1)) { - ifdef(`ERANGE_FILL',`*ip = FillDefaultValue($1);') + `ifelse(index(`$2',`u'), 0, +`if (xx == ($1)Upcase($2)_MAX) *ip = Upcase($2)_MAX;',dnl for unsigned type +`if (xx == ($1)Upcase($2)_MAX) *ip = Upcase($2)_MAX; + else if (xx == Upcase($2)_MIN) *ip = Upcase($2)_MIN;') + else if (xx > (double)Upcase($2)_MAX || xx < Dmin($2)) { + ifdef(`ERANGE_FILL',`*ip = FillDefaultValue($2);') DEBUG_RETURN_ERROR(NC_ERANGE) } - else *ip = ($1)xx;') + else *ip = ($2)xx;') /* * Primitive numeric conversion functions. @@ -541,12 +541,12 @@ APIPrefix`x_get_'NC_TYPE($1)_$2(const void *xp, $2 *ip) { ix_$1 xx; get_ix_$1(xp, &xx); - ifelse(`$1', `float', `ifelse(`$2', `longlong', GETF_CheckBND2($2), - `$2', `ulonglong', GETF_CheckBND2($2), + ifelse(`$1', `float', `ifelse(`$2', `longlong', GETF_CheckBND2($1,$2), + `$2', `ulonglong', GETF_CheckBND2($1,$2), `$2', `double', `*ip = ($2)xx;', GETF_CheckBND($2))', - `$1', `double', `ifelse(`$2', `longlong', GETF_CheckBND2($2), - `$2', `ulonglong', GETF_CheckBND2($2), + `$1', `double', `ifelse(`$2', `longlong', GETF_CheckBND2($1,$2), + `$2', `ulonglong', GETF_CheckBND2($1,$2), GETF_CheckBND($2))', `*ip = ($2)xx;') return NC_NOERR; @@ -609,7 +609,7 @@ APIPrefix`x_put_'NC_TYPE($1)_$2(void *xp, const $2 *ip, void *fillp) int err=NC_NOERR; ix_$1 xx = FillDefaultValue($1); - ifelse(`$2', `double', `if (*ip > Xmax($1) || *ip < DXmin($1)) { + ifelse(`$2', `double', `if (*ip > (double)Xmax($1) || *ip < DXmin($1)) { FillValue($1, &xx) DEBUG_ASSIGN_ERROR(err, NC_ERANGE) } ifdef(`ERANGE_FILL',`else')', diff --git a/src/utils/ncmpidump/ncmpidump.c b/src/utils/ncmpidump/ncmpidump.c index c54662c7d..e8ce61114 100644 --- a/src/utils/ncmpidump/ncmpidump.c +++ b/src/utils/ncmpidump/ncmpidump.c @@ -582,10 +582,10 @@ do_ncdump(const char *path, struct fspec* specp) var.fillval = NC_FILL_DOUBLE; break; case NC_INT64: - var.fillval = NC_FILL_INT64; + var.fillval = (double)NC_FILL_INT64; break; case NC_UINT64: - var.fillval = NC_FILL_UINT64; + var.fillval = (double)NC_FILL_UINT64; break; default: break;