From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0CD7B3858405; Tue, 24 Aug 2021 19:12:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0CD7B3858405 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/102048] __gnu_cxx::rope.erase(size_t __p) implementation seems to be wrong Date: Tue, 24 Aug 2021 19:12:58 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: everconfirmed cf_reconfirmed_on bug_status Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 19:12:59 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102048 Jonathan Wakely changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Last reconfirmed| |2021-08-24 Status|UNCONFIRMED |NEW --- Comment #2 from Jonathan Wakely --- This would fix it, and provide the API that was apparently intended: --- a/libstdc++-v3/include/ext/rope +++ b/libstdc++-v3/include/ext/rope @@ -2401,11 +2401,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION this->_M_tree_ptr =3D __result; } - // Erase, single character - void - erase(size_type __p) - { erase(__p, __p + 1); } - // Insert, iterator variants. iterator insert(const iterator& __p, const rope& __r) If we want to retain an erase function that erases a single character, we c= ould do: @@ -2393,7 +2393,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Erase, (position, size) variant. void - erase(size_type __p, size_type __n) + erase(size_type __p, size_type __n =3D 1) { _RopeRep* __result =3D replace(this->_M_tree_ptr, __p, __p + __n, 0); But to be consistent with std::string it should erase from that position to= the end of the string: @@ -2393,7 +2393,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Erase, (position, size) variant. void - erase(size_type __p, size_type __n) + erase(size_type __p, size_type __n =3D npos) { _RopeRep* __result =3D replace(this->_M_tree_ptr, __p, __p + __n, 0); So maybe we should just remove it, since it's currently broken and "fixing"= it would be inconsistent with std::string.=