Open ossama-othman opened 4 years ago
Related bug documented in lib/marc/map_parameters.h
:
/**
* @brief Maximum valid physical value.
*
* @note This value corresponds to the %FITS "DATAMAX"
* keyword.
*
* @bug On platforms that implement the IEEE 754 floating
* point standard, the use of @c double as the underlying
* @c DATAMAX type will cause loss of precision if the
* %FITS @c DATAMAX values is an integer that requires
* more than 53 bits since the significand of a 64 bit
* IEEE 754 floating point value is only 53 bits wide.
* Special handling will be need to be implemented to
* handle such a case.
*/
MaRC::optional<double> datamax_;
The warning could be silenced by using an explicit cast, but that would only hide the problem in this case. Ideally the code should be changed so that no cast is necessary.
Describe the bug Building MaRC with clang++ 10 or better triggers a warning diagnostic at compile-time related to implicit conversion of a 64 bit integer (
int64_t
) to adouble
floating point value:The crux of the problem is that MaRC "reads" all data from the source images as
double
values. This isn't a problem for 8, 16, and 32 bit integers since their maximum values can be stored in a 64 bitdouble
without loss of precision since the significand of adouble
value has enough bits to store it (e.g. IEEE 754double
is 53 bits wide). However, that isn't the case for 64 bit integers since the largest 64 bit value is obviously won't fit into the smallerdouble
type signficand (e.g. 53 bits).To Reproduce Steps to reproduce the behavior:
./configure CXX=clang++
make check
Expected behavior No warning related to implicit conversion of an integer to a floating point value should be triggered.
Desktop (please complete the following information):