From 13eca00914b5c469b56c7d60b156c8c0bd0e7dee Mon Sep 17 00:00:00 2001 From: paolo Date: Sun, 28 Feb 2010 10:37:04 +0000 Subject: [PATCH] 2010-02-28 Paolo Carlini * src/hash-long-double-aux.cc (hash:: operator()(long double)): Hash both -0 and +0 to 0. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@157120 138bc75d-0d04-0410-961f-82ee72b054a4 --- libstdc++-v3/ChangeLog | 5 +++++ libstdc++-v3/src/hash-long-double-aux.cc | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 564f905cbe0..ef97ea3c0cf 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,8 @@ +2010-02-28 Paolo Carlini + + * src/hash-long-double-aux.cc (hash:: + operator()(long double)): Hash both -0 and +0 to 0. + 2010-02-25 Ed Smith-Rowland <3dw4rd@verizon.net> * include/bits/random.tcc (operator<<): Use max_digits10. diff --git a/libstdc++-v3/src/hash-long-double-aux.cc b/libstdc++-v3/src/hash-long-double-aux.cc index 5b8bbfdd49d..d54d635f83e 100644 --- a/libstdc++-v3/src/hash-long-double-aux.cc +++ b/libstdc++-v3/src/hash-long-double-aux.cc @@ -28,7 +28,9 @@ size_t hash::operator()(long double __val) const { - size_t __result = 0; + // 0 and -0 both hash to zero. + if (__val == 0.0L) + return 0; int __exponent; __val = __builtin_frexpl(__val, &__exponent); @@ -44,7 +46,5 @@ const size_t __coeff = __SIZE_MAX__ / __LDBL_MAX_EXP__; - __result = __hibits + (size_t)__val + __coeff * __exponent; - - return __result; + return __hibits + (size_t)__val + __coeff * __exponent; } -- 2.11.0