The following code in unicode.h: ```c++ constexpr _Iterator operator++(int) { auto __tmp = *this; ++this; return __tmp; } ``` Should instead be: ```c++ constexpr _Iterator operator++(int) { auto __tmp = *this; ++*this; return __tmp; } ``` (`++*this` instead of `++this`).
No ++this is correct. We want to increment the iterator and not the what the iterator points too here.
Which would be ++*this ++this shouldn't even compile.
It fails to compile if that member function is instantiated (which libstdc++ itself never does). /home/jwakely/gcc/15/include/c++/15.0.0/bits/unicode.h:805:11: error: increment of read-only location '(std::__unicode::__v15_1_0::_Grapheme_cluster_view<std::basic_string_view<char> >::_Iterator*)this' 805 | ++this; | ^~~~~~ /home/jwakely/gcc/15/include/c++/15.0.0/bits/unicode.h:805:11: error: lvalue required as increment operand But ++this could be rejected without treating it as a dependent expression. Anyway, I'll fix the library typo.
I've opened PR 115121 for the accepts-invalid compiler bug.
*** Bug 115124 has been marked as a duplicate of this bug. ***
*** Bug 115134 has been marked as a duplicate of this bug. ***
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>: https://gcc.gnu.org/g:c9e05b03c18e898be604ab90401476e9c473cc52 commit r15-629-gc9e05b03c18e898be604ab90401476e9c473cc52 Author: Jonathan Wakely <jwakely@redhat.com> Date: Thu May 16 17:15:55 2024 +0100 libstdc++: Fix typo in _Grapheme_cluster_view::_Iterator [PR115119] libstdc++-v3/ChangeLog: PR libstdc++/115119 * include/bits/unicode.h (_Iterator::operator++(int)): Fix typo in increment expression. * testsuite/ext/unicode/grapheme_view.cc: Check post-increment on view's iterator.
The releases/gcc-14 branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>: https://gcc.gnu.org/g:e909d360dfaeafa9f45eda2461a1bedffac99ac2 commit r14-10215-ge909d360dfaeafa9f45eda2461a1bedffac99ac2 Author: Jonathan Wakely <jwakely@redhat.com> Date: Thu May 16 17:15:55 2024 +0100 libstdc++: Fix typo in _Grapheme_cluster_view::_Iterator [PR115119] libstdc++-v3/ChangeLog: PR libstdc++/115119 * include/bits/unicode.h (_Iterator::operator++(int)): Fix typo in increment expression. * testsuite/ext/unicode/grapheme_view.cc: Check post-increment on view's iterator. (cherry picked from commit c9e05b03c18e898be604ab90401476e9c473cc52)
Fixed for 14.2, thanks for the report (and to the dup reporters).