[PATCH] Fix mul overflow detection for LLP64 arch.
FIXNUMs are expected to fit into a long type, but the test in MUL_OVERFLOW_FIXNUM_P() is about the VALUE type. Since long is smaller than VALUE on LLP64, the overflow is not detected. As an exemplary result "2**31" evaluates to "-2147483648" instead of "2147483648" on Windows when built with gcc-7.1.0.
This also results in many more test failures as described in this github issue: https://github.com/oneclick/rubyinstaller2/issues/55
gcc versions before 7.1.0 don't provide __builtin_mul_overflow_p() and ruby-2.4.x doesn't use this function, so that they don't show this broken behavior.
The attached patch fixes the issue. However I'm currently unable to run a full "make test-all" to verify whether this fixes all gcc-7.1.0 related issues.
Updated by MSP-Greg (Greg L) over 3 years ago
Just updated to gcc 7.1.0, and built trunk
ruby 2.5.0dev (2017-07-15 trunk 59341) [x64-mingw32] with Lars' patch, and all tests results were as expected.
Lars - thanks again. For those that don't know, Lars is the creator of RubyInstaller2 for Windows. My build system is a little different, but both are MSYS2/MinGW based. My build system uses the runtime files he created for RI2, which allow the installation/compiling of extension gems.
Updated by naruse (Yui NARUSE) about 3 years ago
- Status changed from Open to Closed
Applied in changeset trunk|r60019.
Fix overflow detection for LLP64 arch [Bug #13748]
FIXNUMs are expected to fit into a long type, but the test is about a
VALUE type. Since long is < than VALUE on LLP64, the overflow is not
detected. As a result "2**31" evaluates to "-2147483648" on Windows with
patched by Lars Kanis email@example.com