diff --git a/src/grib_accessor_class_unsigned.c b/src/grib_accessor_class_unsigned.c index 37200e0e6..87dd69ff3 100644 --- a/src/grib_accessor_class_unsigned.c +++ b/src/grib_accessor_class_unsigned.c @@ -244,7 +244,7 @@ int pack_long_unsigned_helper(grib_accessor* a, const long* val, size_t *len, in } if (nbits < 33) { unsigned long maxval = (1UL << nbits)-1; - if (v > maxval) { + if (maxval > 0 && v > maxval) { /* See ECC-1002 */ grib_context_log(a->context, GRIB_LOG_ERROR, "Key \"%s\": Trying to encode value of %ld but the maximum allowable value is %ld (number of bits=%ld)\n", a->name, v, maxval, nbits);