mirror of https://github.com/ecmwf/eccodes.git
ECC-1522: prgenv/amd: Test eccodes_t_grib_bpv_limit fails
This commit is contained in:
parent
80f83205ac
commit
adc0450516
|
@ -40,16 +40,17 @@ long grib_get_binary_scale_fact(double max, double min, long bpval, int* ret)
|
||||||
long scale = 0;
|
long scale = 0;
|
||||||
const long last = 127; /* Depends on edition, should be parameter */
|
const long last = 127; /* Depends on edition, should be parameter */
|
||||||
unsigned long maxint = 0;
|
unsigned long maxint = 0;
|
||||||
|
const size_t ulong_size = sizeof(maxint) * 8;
|
||||||
|
|
||||||
/* See ECC-246
|
/* See ECC-246
|
||||||
unsigned long maxint = grib_power(bpval,2) - 1;
|
unsigned long maxint = grib_power(bpval,2) - 1;
|
||||||
double dmaxint=(double)maxint;
|
double dmaxint=(double)maxint;
|
||||||
*/
|
*/
|
||||||
const double dmaxint = grib_power(bpval, 2) - 1;
|
if (bpval >= ulong_size) {
|
||||||
if (dmaxint >= ULONG_MAX) {
|
|
||||||
*ret = GRIB_OUT_OF_RANGE; /*overflow*/
|
*ret = GRIB_OUT_OF_RANGE; /*overflow*/
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
const double dmaxint = grib_power(bpval, 2) - 1;
|
||||||
maxint = (unsigned long)dmaxint; /* Now it's safe to cast */
|
maxint = (unsigned long)dmaxint; /* Now it's safe to cast */
|
||||||
|
|
||||||
*ret = 0;
|
*ret = 0;
|
||||||
|
|
Loading…
Reference in New Issue