From a3ee88517c7ecef0f29c7af15af31db5dd18d451 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Wed, 13 Aug 2014 11:24:35 +0000 Subject: [PATCH] re PR libstdc++/62118 (cases under libstdc++-v3/testsuite/ext/ failed on aarch64/arm) 2014-08-13 Paolo Carlini PR libstdc++/62118 * include/ext/random.tcc (uniform_on_sphere_helper<2, _RealType>:: operator()): Use std::hypot only when _GLIBCXX_USE_C99_MATH_TR1. From-SVN: r213906 --- libstdc++-v3/ChangeLog | 6 ++++++ libstdc++-v3/include/ext/random.tcc | 10 ++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 7b411f3e60d..0f51eb493cf 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,9 @@ +2014-08-13 Paolo Carlini + + PR libstdc++/62118 + * include/ext/random.tcc (uniform_on_sphere_helper<2, _RealType>:: + operator()): Use std::hypot only when _GLIBCXX_USE_C99_MATH_TR1. + 2014-08-12 Jonathan Wakely * include/bits/basic_string.h (getline): Qualify call to prevent ADL diff --git a/libstdc++-v3/include/ext/random.tcc b/libstdc++-v3/include/ext/random.tcc index 997c204ffe2..9aef359adc9 100644 --- a/libstdc++-v3/include/ext/random.tcc +++ b/libstdc++-v3/include/ext/random.tcc @@ -1547,10 +1547,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template class uniform_on_sphere_helper { - typedef typename uniform_on_sphere_distribution<_Dimen, _RealType>::result_type result_type; + typedef typename uniform_on_sphere_distribution<_Dimen, _RealType>:: + result_type result_type; public: - template + template result_type operator()(_NormalDistribution& __nd, _UniformRandomNumberGenerator& __urng) { @@ -1604,9 +1606,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } while (__sq == _RealType(0) || __sq > _RealType(1)); +#if _GLIBCXX_USE_C99_MATH_TR1 // Yes, we do not just use sqrt(__sq) because hypot() is more // accurate. auto __norm = std::hypot(__ret[0], __ret[1]); +#else + auto __norm = std::sqrt(__ret[0] * __ret[0] + __ret[1] * __ret[1]); +#endif __ret[0] /= __norm; __ret[1] /= __norm;