Created on 2010-08-25.00:00:00 last changed 171 months ago
Proposed resolution:
Change the wording in [ratio.arithmetic] p. 2-5 as follows:
template <class R1, class R2> using ratio_add = see below;2 The type ratio_add<R1, R2> shall be a synonym for
ratio<T1, T2>ratio<U, V> such that ratio<U, V>::num and ratio<U, V>::den are the same as the corresponding members of ratio<T1, T2> would be in the absence of arithmetic overflow where T1 has the value R1::num * R2::den + R2::num * R1::den and T2 has the value R1::den * R2::den. If the required values of ratio<U, V>::num and ratio<U, V>::den cannot be represented in intmax_t then the program is ill-formed.
template <class R1, class R2> using ratio_subtract = see below;3 The type ratio_subtract<R1, R2> shall be a synonym for
ratio<T1, T2>ratio<U, V> such that ratio<U, V>::num and ratio<U, V>::den are the same as the corresponding members of ratio<T1, T2> would be in the absence of arithmetic overflow where T1 has the value R1::num * R2::den - R2::num * R1::den and T2 has the value R1::den * R2::den. If the required values of ratio<U, V>::num and ratio<U, V>::den cannot be represented in intmax_t then the program is ill-formed.
template <class R1, class R2> using ratio_multiply = see below;4 The type ratio_multiply<R1, R2> shall be a synonym for
ratio<T1, T2>ratio<U, V> such that ratio<U, V>::num and ratio<U, V>::den are the same as the corresponding members of ratio<T1, T2> would be in the absence of arithmetic overflow where T1 has the value R1::num * R2::num and T2 has the value R1::den * R2::den. If the required values of ratio<U, V>::num and ratio<U, V>::den cannot be represented in intmax_t then the program is ill-formed.
template <class R1, class R2> using ratio_divide = see below;5 The type ratio_divide<R1, R2> shall be a synonym for
ratio<T1, T2>ratio<U, V> such that ratio<U, V>::num and ratio<U, V>::den are the same as the corresponding members of ratio<T1, T2> would be in the absence of arithmetic overflow where T1 has the value R1::num * R2::den and T2 has the value R1::den * R2::num. If the required values of ratio<U, V>::num and ratio<U, V>::den cannot be represented in intmax_t then the program is ill-formed.
[ Batavia: Resolved by accepting n3210. ]
[ 2010-10-25 Daniel adds: ]
Accepting n3131 would solve this issue.
Addresses GB-89
The alias representations of the ratio arithmetic templates do not allow implementations to avoid overflow, since they explicitly specify the form of the aliased template instantiation. For example ratio_multiply, ratio<2, LLONG_MAX> is required to alias ratio<2*LLONG_MAX, LLONG_MAX*2>, which overflows, so is ill-formed. However, this is trivially equal to ratio<1, 1>. It also contradicts the opening statement of [ratio.arithmetic] p. 1 "implementations may use other algorithms to compute these values".
History | |||
---|---|---|---|
Date | User | Action | Args |
2010-11-18 12:46:23 | admin | set | status: nad editorial -> resolved |
2010-11-13 01:42:55 | admin | set | messages: + msg5346 |
2010-11-13 01:42:55 | admin | set | status: open -> nad editorial |
2010-10-25 21:29:27 | admin | set | messages: + msg5133 |
2010-10-24 10:50:39 | admin | set | messages: + msg5007 |
2010-08-25 00:00:00 | admin | create |