Subject: [Boost-bugs] [Boost C++ Libraries] #13558: gcd(INT_MIN, INT_MIN) crashes
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2018-05-02 20:28:08
#13558: gcd(INT_MIN, INT_MIN) crashes
--------------------------------------+---------------------
Reporter: Evan Driscoll <evaned@â¦> | Owner: (none)
Type: Bugs | Status: new
Milestone: To Be Determined | Component: None
Version: Boost 1.67.0 | Severity: Problem
Keywords: |
--------------------------------------+---------------------
The following produces a SIGFPE for me:
{{{#!c++
#include <iostream>
#include <climits>
#include <boost/integer/common_factor_rt.hpp>
int main()
{
std::cout << boost::integer::gcd(INT_MIN, INT_MIN);
}
}}}
because it simplifies `gcd(INT_MIN, INT_MIN)` => `gcd(INT_MIN % INT_MIN,
INT_MIN)` => `gcd(0, INT_MIN)` => `gcd(0, INT_MIN % 0)` => gcd(0,
SIGFPE)`.
I'm actually not sure what the right behavior is (the documented behavior
is that the return is always positive, and, for example, `gcd(-2, -2)`
returns 2, but obviously you can't do that here).
Boost 1.63 returned `INT_MIN` in this case, which seems like the best
answer.
Responsible commit:
https://github.com/boostorg/integer/commit/beb68718640150f67fe5671bbbb7848d9e7170b8
-- Ticket URL: <https://svn.boost.org/trac10/ticket/13558> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2018-05-02 20:32:50 UTC