expressions: Convert SYSMIS into int as INT_MIN during optimization too.
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 10 Apr 2022 15:47:00 +0000 (08:47 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 10 Apr 2022 15:47:00 +0000 (08:47 -0700)
In an expression like LPAD('abc', $sysmis), the LPAD function is evaluated
using a C function that takes an 'int' as its second argument.  During
expression evaluation, out-of-range values get converted into SYSMIS by
the NUM_TO_INTEGER operator that gets automatically inserted to ensure
that, and then SYSMIS gets converted into INT_MIN to pass to the C
function.  This worked OK for runtime evaluation, but the optimizer failed
to do the conversion of SYSMIS to INT_MIN, which yielded undefined
behavior.  Some platforms (e.g. GCC on x86) converted SYSMIS (which is
the second-smallest 'double' value) into INT_MIN, so no problem showed up
there, but other platforms yielded INT_MAX, causing unexpected failures.

This commit fixes the problem by explicitly converting SYSMIS into INT_MIN
during optimization.

Thanks to Friedrich Beckmann for reporting and uncovering the problem.
Bug #62267.


No differences found