Fix checks for valid integer range subset of 'double'.
commit505a04fe4cf5cb6f81b498e997898e6069387791
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 23 Apr 2023 01:05:44 +0000 (22 18:05 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 23 Apr 2023 01:06:06 +0000 (22 18:06 -0700)
treebee55cb44e6776bfe0ca39b63dfe67a942721a69
parent27b725e6d02cbea19b1435ffbaaa9ef5e87f0435
Fix checks for valid integer range subset of 'double'.

Previously, I assumed that checking that a 'double' was between LONG_MIN
and LONG_MAX meant that it would convert to a sensible 'long'.  This is
wrong, because LONG_MAX rounds up to a higher 'double', because it has too
many bits for a 53-bit mantissa.  This could cause problems, like for
example LONG_MAX (as a double) turns out to convert back to LONG_MIN (as a
'long').  This commit fixes the problem.

Thanks to Youngseok Choi for reporting the problem.
Reported at https://lists.gnu.org/archive/html/bug-gnu-pspp/2023-04/msg00005.html.
src/language/commands/matrix.c
src/language/lexer/lexer.c
src/language/lexer/token.c
src/libpspp/automake.mk
src/libpspp/float-range.h [new file with mode: 0644]
tests/language/commands/matrix.at