id summary reporter owner description type status milestone component version severity resolution keywords cc 6092 input from non integral durations makes the compiler fail viboes viboes "The following input 1.0 seconds makes the compiler fails when trying to extract the duration duration d; cin >> d; {{{ ../../../boost/math/common_factor_rt.hpp: In function ‘RingType boost::math::detail::gcd_euclidean(RingType, RingType) [with RingType = long double]’: ../../../boost/math/common_factor_rt.hpp:122: instantiated from ‘IntegerType boost::math::detail::gcd_integer(const IntegerType&, const IntegerType&) [with IntegerType = long double]’ ../../../boost/math/common_factor_rt.hpp:240: instantiated from ‘T boost::math::detail::gcd_optimal_evaluator_helper_t::operator()(const T&, const T&) [with T = long double]’ ../../../boost/math/common_factor_rt.hpp:290: instantiated from ‘T boost::math::detail::gcd_optimal_evaluator::operator()(const T&, const T&) [with T = long double]’ ../../../boost/math/common_factor_rt.hpp:442: instantiated from ‘T boost::math::detail::gcd_optimal(const T&, const T&) [with T = long double]’ ../../../boost/math/common_factor_rt.hpp:473: instantiated from ‘typename boost::math::gcd_evaluator::result_type boost::math::gcd_evaluator::operator()(const IntegerType&, const IntegerType&) const [with IntegerType = long double]’ ../../../boost/math/common_factor_rt.hpp:505: instantiated from ‘IntegerType boost::math::gcd(const IntegerType&, const IntegerType&) [with IntegerType = long double]’ ../../../boost/chrono/io/duration_get.hpp:239: instantiated from ‘InputIterator boost::chrono::duration_get::get(InputIterator, InputIterator, std::ios_base&, std::_Ios_Iostate&, boost::chrono::duration&, const CharT*, const CharT*) const [with Rep = double, Period = boost::ratio<1l, 1l>, CharT = char, InputIterator = std::istreambuf_iterator >]’ ../../../boost/chrono/io/duration_get.hpp:294: instantiated from ‘InputIterator boost::chrono::duration_get::get(InputIterator, InputIterator, std::ios_base&, std::_Ios_Iostate&, boost::chrono::duration&) const [with Rep = double, Period = boost::ratio<1l, 1l>, CharT = char, InputIterator = std::istreambuf_iterator >]’ ../../../boost/chrono/io/duration_io.hpp:593: instantiated from ‘std::basic_istream<_CharT, _Traits>& boost::chrono::operator>>(std::basic_istream<_CharT, _Traits>&, boost::chrono::duration&) [with CharT = char, Traits = std::char_traits, Rep = double, Period = boost::ratio<1l, 1l>]’ io/duration_input.cpp:15: instantiated from ‘void test_good(const char*, D) [with D = boost::chrono::duration >]’ io/duration_input.cpp:52: instantiated from here ../../../boost/math/common_factor_rt.hpp:102: error: invalid operands of types ‘long double’ and ‘long double’ to binary ‘operator%’ ../../../boost/math/common_factor_rt.hpp:102: error: in evaluation of ‘operator%=(long double, long double)’ ../../../boost/math/common_factor_rt.hpp:106: error: invalid operands of types ‘long double’ and ‘long double’ to binary ‘operator%’ ../../../boost/math/common_factor_rt.hpp:106: error: in evaluation of ‘operator%=(long double, long double)’ }}} This is because the common type is a double and gcd doesn't works for it. {{{ // if (is_integral::value) // { // // Reduce r * num / den // common_type_t t = math::gcd(r, den); // r /= t; // den /= t; // if (den != 1) // { // // Conversion to Period is integral and not exact // is.setstate(is.failbit); // return is; // } // } }}} This code could be replaced by a template to avoid the bad code to be instantiated. {{{ template typename enable_if, bool>::type reduce(intermediate_type& r, unsigned long long& den, std::ios_base::iostate& err) { typedef typename common_type::type common_type_t; // Reduce r * num / den common_type_t t = math::gcd(common_type_t(r), common_type_t(den)); r /= t; den /= t; if (den != 1) { // Conversion to Period is integral and not exact err |= std::ios_base::failbit; return false; } return true; } template typename disable_if, bool>::type reduce(intermediate_type& , unsigned long long& , std::ios_base::iostate& ) { return true; } }}} " Bugs closed Boost 1.49.0 chrono Boost 1.47.0 Problem fixed