|
|
5cc31e |
2019-03-11 Jonathan Wakely <jwakely@redhat.com>
|
|
|
5cc31e |
|
|
|
5cc31e |
PR libstdc++/89629
|
|
|
5cc31e |
* libsupc++/hash_bytes.cc [__SIZEOF_SIZE_T__ == 8] (_Hash_bytes):
|
|
|
5cc31e |
Use correct type for len_aligned.
|
|
|
5cc31e |
* testsuite/20_util/hash/89629.cc: New test.
|
|
|
5cc31e |
|
|
|
5cc31e |
--- libstdc++-v3/libsupc++/hash_bytes.cc (revision 269583)
|
|
|
5cc31e |
+++ libstdc++-v3/libsupc++/hash_bytes.cc (revision 269584)
|
|
|
5cc31e |
@@ -139,7 +139,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
|
5cc31e |
|
|
|
5cc31e |
// Remove the bytes not divisible by the sizeof(size_t). This
|
|
|
5cc31e |
// allows the main loop to process the data as 64-bit integers.
|
|
|
5cc31e |
- const int len_aligned = len & ~0x7;
|
|
|
5cc31e |
+ const size_t len_aligned = len & ~(size_t)0x7;
|
|
|
5cc31e |
const char* const end = buf + len_aligned;
|
|
|
5cc31e |
size_t hash = seed ^ (len * mul);
|
|
|
5cc31e |
for (const char* p = buf; p != end; p += 8)
|
|
|
5cc31e |
--- libstdc++-v3/testsuite/20_util/hash/89629.cc (nonexistent)
|
|
|
5cc31e |
+++ libstdc++-v3/testsuite/20_util/hash/89629.cc (revision 269584)
|
|
|
5cc31e |
@@ -0,0 +1,43 @@
|
|
|
5cc31e |
+// Copyright (C) 2019 Free Software Foundation, Inc.
|
|
|
5cc31e |
+//
|
|
|
5cc31e |
+// This file is part of the GNU ISO C++ Library. This library is free
|
|
|
5cc31e |
+// software; you can redistribute it and/or modify it under the
|
|
|
5cc31e |
+// terms of the GNU General Public License as published by the
|
|
|
5cc31e |
+// Free Software Foundation; either version 3, or (at your option)
|
|
|
5cc31e |
+// any later version.
|
|
|
5cc31e |
+
|
|
|
5cc31e |
+// This library is distributed in the hope that it will be useful,
|
|
|
5cc31e |
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
5cc31e |
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
5cc31e |
+// GNU General Public License for more details.
|
|
|
5cc31e |
+
|
|
|
5cc31e |
+// You should have received a copy of the GNU General Public License along
|
|
|
5cc31e |
+// with this library; see the file COPYING3. If not see
|
|
|
5cc31e |
+// <http://www.gnu.org/licenses/>.
|
|
|
5cc31e |
+
|
|
|
5cc31e |
+// { dg-do run { target { lp64 || llp64 } } }
|
|
|
5cc31e |
+// { dg-require-effective-target c++11 }
|
|
|
5cc31e |
+// { dg-require-effective-target run_expensive_tests }
|
|
|
5cc31e |
+
|
|
|
5cc31e |
+#include <functional>
|
|
|
5cc31e |
+#include <string>
|
|
|
5cc31e |
+
|
|
|
5cc31e |
+void
|
|
|
5cc31e |
+test01()
|
|
|
5cc31e |
+{
|
|
|
5cc31e |
+ const std::size_t big = std::size_t(1) << 31;
|
|
|
5cc31e |
+ std::string s;
|
|
|
5cc31e |
+ try {
|
|
|
5cc31e |
+ s.resize(big, 'a');
|
|
|
5cc31e |
+ } catch (const std::bad_alloc&) {
|
|
|
5cc31e |
+ return; // try to avoid a FAIL if memory allocation fails
|
|
|
5cc31e |
+ }
|
|
|
5cc31e |
+ // PR libstdc++/89629
|
|
|
5cc31e |
+ (void) std::hash<std::string>{}(s);
|
|
|
5cc31e |
+}
|
|
|
5cc31e |
+
|
|
|
5cc31e |
+int
|
|
|
5cc31e |
+main()
|
|
|
5cc31e |
+{
|
|
|
5cc31e |
+ test01();
|
|
|
5cc31e |
+}
|