From 6442533f5fb82120722f66163edba62e1bdb055d Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Sun, 12 Mar 2023 19:25:34 +0000 Subject: [PATCH] ECC-455: Set of missingValue key in grib_filter not working as expected --- src/grib_expression_class_double.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/grib_expression_class_double.cc b/src/grib_expression_class_double.cc index b123dc1c3..387c716ec 100644 --- a/src/grib_expression_class_double.cc +++ b/src/grib_expression_class_double.cc @@ -87,7 +87,13 @@ static void init_class(grib_expression_class* c) static int evaluate_long(grib_expression* g, grib_handle* h, long* lres) { grib_expression_double* e = (grib_expression_double*)g; - *lres = e->value; + + if ( (long)(e->value) != e->value) { + grib_context_log(h->context, GRIB_LOG_ERROR, + "Converting %g to an integer leads to a possible loss of precision", e->value); + return GRIB_WRONG_CONVERSION; + } + *lres = e->value; return GRIB_SUCCESS; }