Skip to content

Commit

Permalink
icc complains conversion from 'long long' to 'float'
Browse files Browse the repository at this point in the history
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__
                    ^~~~~~~~~~~~~~~~~
 <built-in>:52:27: note: expanded from here
 #define __LONG_LONG_MAX__ 9223372036854775807LL
                           ^~~~~~~~~~~~~~~~~~~~~
  • Loading branch information
wkliao committed Sep 5, 2023
1 parent 2dc59b4 commit 92ba286
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
26 changes: 13 additions & 13 deletions src/drivers/common/ncx.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
Expand Down Expand Up @@ -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')',
Expand Down
4 changes: 2 additions & 2 deletions src/utils/ncmpidump/ncmpidump.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 92ba286

Please sign in to comment.