r265625 - in /trunk/libstdc++-v3: ChangeLog inc...

redi@gcc.gnu.org redi@gcc.gnu.org
Tue Oct 30 14:49:00 GMT 2018


Author: redi
Date: Tue Oct 30 14:49:32 2018
New Revision: 265625

URL: https://gcc.gnu.org/viewcvs?rev=265625&root=gcc&view=rev
Log:
PR libstdc++/87784 fix dynamic_bitset::push_back

Previously the _M_Nb member was incremented before calling
_M_unchecked_set which meant that the bit being set was out of bounds.
It either set the wrong bit in an allocated word, or accessed beyond the
end of the allocated memory in the _M_w vector. The fix for the bug is
to update the _M_Nb member after using it as an index.

As an optimisation, when a new block needs to be appended the call to
_M_unchecked_set can be avoided by appending a block with the least
significant bit already set to the desired value.

	PR libstdc++/87784
	* include/tr2/dynamic_bitset (dynamic_bitset::push_back): When there
	are no unused bits in the last block, append a new block with the
	right value so the bit doesn't need to be set. Only increment size
	after setting the new bit, not before.
	* testsuite/tr2/dynamic_bitset/pr87784.cc: New test.

Added:
    trunk/libstdc++-v3/testsuite/tr2/dynamic_bitset/pr87784.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/tr2/dynamic_bitset



More information about the Libstdc++-cvs mailing list