Boost C++ Libraries: Ticket #13613: gcd performs modulo by zero which is undefined https://svn.boost.org/trac10/ticket/13613 <p> 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: </p> <p> CID 293013 (<a href="https://svn.boost.org/trac10/query?id=4-12" title="Tickets 4-12">#4-12</a> 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] </p> <p> (rational_test.cpp) 470 BOOST_CHECK_EQUAL( boost::gcd&lt;T&gt;( 0, -9), static_cast&lt;T&gt;( 9) ); </p> <p> (rational.hpp) <a class="missing wiki">IntType</a> gcd(<a class="missing wiki">IntType</a> n, <a class="missing wiki">IntType</a> m) { </p> <blockquote> <p> <em> Defer to the version in Boost.Integer </em></p> </blockquote> <blockquote class="citation"> <ol><li>divide_arg: n is used as a divisor in function gcd. </li></ol></blockquote> <blockquote> <p> return integer::gcd( n, m ); </p> </blockquote> <p> } </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13613 Trac 1.4.3