This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/70463] always use first element of mutex pool in src/c++11/shared_ptr.cc
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 05 Apr 2016 15:08:03 +0000
- Subject: [Bug libstdc++/70463] always use first element of mutex pool in src/c++11/shared_ptr.cc
- Auto-submitted: auto-generated
- References: <bug-70463-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70463
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2016-04-05
Ever confirmed|0 |1
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This would shift the address right to remove the bits that are always zero:
--- a/libstdc++-v3/src/c++11/shared_ptr.cc
+++ b/libstdc++-v3/src/c++11/shared_ptr.cc
@@ -41,7 +41,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
const unsigned char invalid = mask + 1;
inline unsigned char key(const void* addr)
- { return _Hash_impl::hash(addr) & mask; }
+ {
+ const int zero_bits = __builtin_ctz(alignof(shared_ptr<void>));
+ return _Hash_impl::hash(addzero_bitsaligned) & mask; }
/* Returns different instances of __mutex depending on the passed address
* in order to limit contention.