[PR libstdc++/58804][PR libstdc++/58729] tr2/dynamic_bitset issues.

Ed Smith-Rowland 3dw4rd@verizon.net
Mon Oct 21 00:02:00 GMT 2013


Greetings.

Here is a patch to correct tr2/dynamic_bitset to use __builtin_xxxll for 
long long instead of the long versions.

Relevant bugs:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58804
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58729

Builds and *really* tests clean on x86_64-linux.

OK?

-------------- next part --------------
Index: include/tr2/dynamic_bitset
===================================================================
--- include/tr2/dynamic_bitset	(revision 203841)
+++ include/tr2/dynamic_bitset	(working copy)
@@ -287,7 +287,7 @@
 	  if (_M_w[__i] != ~static_cast<block_type>(0))
 	    return 0;
 	return ((this->_M_w.size() - 1) * _S_bits_per_block
-		+ __builtin_popcountl(this->_M_hiword()));
+		+ __builtin_popcountll(this->_M_hiword()));
       }
 
       bool
@@ -332,7 +332,7 @@
       {
 	size_t __result = 0;
 	for (size_t __i = 0; __i < this->_M_w.size(); ++__i)
-	  __result += __builtin_popcountl(this->_M_w[__i]);
+	  __result += __builtin_popcountll(this->_M_w[__i]);
 	return __result;
       }
 
Index: include/tr2/dynamic_bitset.tcc
===================================================================
--- include/tr2/dynamic_bitset.tcc	(revision 203841)
+++ include/tr2/dynamic_bitset.tcc	(working copy)
@@ -131,7 +131,7 @@
 	  _WordT __thisword = this->_M_w[__i];
 	  if (__thisword != static_cast<_WordT>(0))
 	    return (__i * _S_bits_per_block
-		    + __builtin_ctzl(__thisword));
+		    + __builtin_ctzll(__thisword));
 	}
       // not found, so return an indication of failure.
       return __not_found;
@@ -158,7 +158,7 @@
 
       if (__thisword != static_cast<_WordT>(0))
 	return (__i * _S_bits_per_block
-		+ __builtin_ctzl(__thisword));
+		+ __builtin_ctzll(__thisword));
 
       // check subsequent words
       for (++__i; __i < this->_M_w.size(); ++__i)
@@ -166,7 +166,7 @@
 	  __thisword = this->_M_w[__i];
 	  if (__thisword != static_cast<_WordT>(0))
 	    return (__i * _S_bits_per_block
-		    + __builtin_ctzl(__thisword));
+		    + __builtin_ctzll(__thisword));
 	}
       // not found, so return an indication of failure.
       return __not_found;
-------------- next part --------------
2013-10-20  Edward Smith-Rowland  <3dw4rd@verizon.net>

	PR libstdc++/58804
	PR libstdc++/58729
	* include/tr2/dynamic_bitset
	(__dynamic_bitset_base<_WordT, _Alloc>::_M_are_all_aux,
	__dynamic_bitset_base<_WordT, _Alloc>::_M_do_count):
	Use __builtin_popcountll() instead of __builtin_popcountl().
	* include/tr2/dynamic_bitset.tcc
	(__dynamic_bitset_base<_WordT, _Alloc>::_M_do_find_first,
	__dynamic_bitset_base<_WordT, _Alloc>::_M_do_find_next):
	Use __builtin_ctzll() instead of __builtin_ctzl().


More information about the Libstdc++ mailing list