Subject: [Boost-bugs] [Boost C++ Libraries] #13613: gcd performs modulo by zero which is undefined
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2018-06-20 12:45:53
#13613: gcd performs modulo by zero which is undefined
--------------------------------+---------------------------
Reporter: James E. King, III | Owner: Daryle Walker
Type: Bugs | Status: new
Milestone: To Be Determined | Component: integer
Version: Boost 1.67.0 | Severity: Problem
Keywords: ub |
--------------------------------+---------------------------
Boost.Rational uses Boost.Integer's gcd method. I Added Coverity Scan
support to the Boost.Rational build and it identified an issue that needs
investigation:
CID 293013 (#4-12 of 12): Division or modulo by zero (DIVIDE_BY_ZERO)
divide_by_zero: In function call gcd, modulo by expression 0 has undefined
behavior. [hide details]
(rational_test.cpp)
470 BOOST_CHECK_EQUAL( boost::gcd<T>( 0, -9), static_cast<T>( 9) );
(rational.hpp)
IntType gcd(IntType n, IntType m)
{
// Defer to the version in Boost.Integer
> 1. divide_arg: n is used as a divisor in function gcd.
return integer::gcd( n, m );
}
-- Ticket URL: <https://svn.boost.org/trac10/ticket/13613> 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-06-20 12:50:47 UTC