Commit 91e4938b by Marc Glisse Committed by Paolo Carlini

PR libstdc++/47913 (again)

2011-05-04  Marc Glisse  <marc.glisse@normalesup.org>

	PR libstdc++/47913 (again)
	* include/std/ratio (ratio_add, ratio_less): Rewrite.
	* testsuite/20_util/ratio/operations/47913.cc: Extend.
	* testsuite/20_util/ratio/cons/cons_overflow_neg.cc: Adjust dg-error
	line numbers.
	* testsuite/20_util/ratio/operations/ops_overflow_neg.cc: Likewise.

From-SVN: r173400
parent 40fda55b
2011-05-04 Marc Glisse <marc.glisse@normalesup.org>
PR libstdc++/47913 (again)
* include/std/ratio (ratio_add, ratio_less): Rewrite.
* testsuite/20_util/ratio/operations/47913.cc: Extend.
* testsuite/20_util/ratio/cons/cons_overflow_neg.cc: Adjust dg-error
line numbers.
* testsuite/20_util/ratio/operations/ops_overflow_neg.cc: Likewise.
2011-05-03 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/48848
......
......@@ -49,6 +49,6 @@ test04()
// { dg-error "instantiated from here" "" { target *-*-* } 34 }
// { dg-error "instantiated from here" "" { target *-*-* } 40 }
// { dg-error "instantiated from here" "" { target *-*-* } 46 }
// { dg-error "denominator cannot be zero" "" { target *-*-* } 155 }
// { dg-error "out of range" "" { target *-*-* } 156 }
// { dg-error "denominator cannot be zero" "" { target *-*-* } 268 }
// { dg-error "out of range" "" { target *-*-* } 269 }
// { dg-error "overflow in constant expression" "" { target *-*-* } 99 }
......@@ -19,6 +19,7 @@
// <http://www.gnu.org/licenses/>.
#include <ratio>
#include <limits>
#include <testsuite_hooks.h>
// libstdc++/47913
......@@ -27,12 +28,32 @@ void test01()
bool test __attribute__((unused)) = true;
using namespace std;
const intmax_t m = (intmax_t)1 << (4 * sizeof(intmax_t) - 1);
typedef ratio_add<ratio<1, (m - 1) * (m - 2)>,
ratio<1, (m - 3) * (m - 2)> > ra_type;
VERIFY( ra_type::num == 2 );
VERIFY( ra_type::den == (m - 1) * (m - 3) );
const intmax_t m1 = (intmax_t)1 << (4 * sizeof(intmax_t) - 1);
typedef ratio_add<ratio<1, (m1 - 1) * (m1 - 2)>,
ratio<1, (m1 - 3) * (m1 - 2)> > ra_type1;
VERIFY( ra_type1::num == 2 );
VERIFY( ra_type1::den == (m1 - 1) * (m1 - 3) );
const intmax_t m2 = numeric_limits<intmax_t>::max();
typedef ratio_add<ratio<m2, 2>,
ratio<-m2, 3> > ra_type2;
VERIFY( ra_type2::num == m2 );
VERIFY( ra_type2::den == 6 );
typedef ratio_add<ratio<m2 / 7 * 5 - 1, 5>,
ratio<-m2 + 2, 7> > ra_type3;
ra_type3();
const intmax_t m3 = numeric_limits<intmax_t>::max() - 1;
typedef ratio_add<ratio<-m3 / 7 * 5 - 1, 5>,
ratio<m3, 7> > ra_type4;
ra_type4();
const intmax_t m4 = numeric_limits<intmax_t>::max() / 2;
typedef ratio_add<ratio<m4 - 5, 15>,
ratio<m4, 35> > ra_type5;
VERIFY( ra_type5::num == (2 * m4 - 7) );
VERIFY( ra_type5::den == 21 );
}
int main()
......
......@@ -39,7 +39,7 @@ test02()
// { dg-error "instantiated from here" "" { target *-*-* } 29 }
// { dg-error "instantiated from here" "" { target *-*-* } 35 }
// { dg-error "instantiated from here" "" { target *-*-* } 36 }
// { dg-error "overflow in addition" "" { target *-*-* } 132 }
// { dg-error "overflow in addition" "" { target *-*-* } 432 }
// { dg-error "overflow in multiplication" "" { target *-*-* } 104 }
// { dg-error "overflow in multiplication" "" { target *-*-* } 100 }
// { dg-error "overflow in multiplication" "" { target *-*-* } 102 }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment