]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Fix __max_diff_type::operator>>= for negative values
authorPatrick Palka <ppalka@redhat.com>
Mon, 24 Apr 2023 17:39:54 +0000 (13:39 -0400)
committerPatrick Palka <ppalka@redhat.com>
Mon, 24 Apr 2023 17:39:54 +0000 (13:39 -0400)
commit83470a5cd4c3d233e1d55b5e5553e1b9c553bf28
treea49d6b2ed234bd9695168943c220707ffa22d933
parentf1f5cbaa3f716fcb472dee52b8a159ccd5576828
libstdc++: Fix __max_diff_type::operator>>= for negative values

This patch fixes sign bit propagation when right-shifting a negative
__max_diff_type value by more than one, a bug that our existing test
coverage didn't expose until r14-159-g03cebd304955a6 fixed the front
end's 'signed typedef-name' handling that the test relies on (which is
a non-standard extension to the language grammar).

libstdc++-v3/ChangeLog:

* include/bits/max_size_type.h (__max_diff_type::operator>>=):
Fix propagation of sign bit.
* testsuite/std/ranges/iota/max_size_type.cc: Avoid using the
non-standard 'signed typedef-name'.  Add some compile-time tests
for right-shifting a negative __max_diff_type value by more than
one.
libstdc++-v3/include/bits/max_size_type.h
libstdc++-v3/testsuite/std/ranges/iota/max_size_type.cc