]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Fix typos in iterator increment for std::text_encoding [PR117520]
authorJonathan Wakely <jwakely@redhat.com>
Mon, 11 Nov 2024 11:54:00 +0000 (11:54 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Mon, 11 Nov 2024 18:57:16 +0000 (18:57 +0000)
commit128f6a6d7af9cf187d59c1dbd9e59f5b782e17c8
treed0ed287555769a925dede95da203bc4ec08bc90b
parentd8992f70a59b178de85305c542eb45d1676bf0a9
libstdc++: Fix typos in iterator increment for std::text_encoding [PR117520]

The intended behaviour for std::text_encoding::aliases_view's iterator
is that it incrementing or decrementing too far sets it to a
value-initialized state, or fails an assertion when those are enabled.
There were typos that used == instead of = which meant that instead of
becoming singular or aborting, an out-of-range increment just did
nothing. This meant erroneous operations were well-defined and didn't
produce any undefined behaviour, but were not diagnosed with assertions
enabled, as had been intended.

This change fixes the bugs and adds more tests to verify the intended
behaviour.

libstdc++-v3/ChangeLog:

PR libstdc++/117520
* include/std/text_encoding (aliases_view:_Iterator::operator+=):
Fix typos that caused == to be used instead of =.
(aliases_view::_Iterator): Fix friend declaration.
* testsuite/std/text_encoding/members.cc: Adjust expected
behaviour of invalid subscript. Add tests for other erroneous
operations on iterators.
libstdc++-v3/include/std/text_encoding
libstdc++-v3/testsuite/std/text_encoding/members.cc