Incredible bug found in __gnu_cxx::rope
Difference between en3 and en4, changed 363 character(s)
Today when I took part in the Round #740 solving problem [D. Top-Notch Insertions](https://codeforces.me/contest/1558/problem/D), [my submission](https://codeforces.me/contest/1558/submission/126903561) failed on test 2 without knowing why. After asserting I found that rope contains unwanted contents and I didn't fix the problem during the contest.↵

However, when I replace all `__gnu_cxx::rope.erase(x)` into `__gnu_cxx::rope.erase(x, 1)`, my code works fine (idk if it will pass system test or not; at least, it passes asserting that all elements are rolled back to the initial state).↵

Then! I found it unbelievable to see the following code from [here](http://www.aoc.nrao.edu/php/tjuerges/ALMA/STL/html-4.1.2/rope-source.html#l02310):↵

![ ](/predownloaded/ad/58/ad5833f2cffab1ebc845091a0cefe4e25cb2533c.png)↵


Look at the line 2318, comments: `Erase, single character`.↵

However, it calls `erase(__p, __p + 1);`, who will erase `__p + 1` characters starting from the position `__p`. ↵

I found it incredible since it's part of libstdc++. I don't know if there's a way to report such failure. Could anyone tell me if I can do something with it? (or instead, NEVER USE SUCH FUNCTION IN THE FUTURE)↵

Thank you!


**UPD**: I've submitted the [bug](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102048) to gcc.↵

Fortunately, it's quickly replied by Jonathan Wakely. Unfortunately, just exactly as [user:adamant,2021-08-24] predicted, Jonathan Wakely wrotes:↵

> We should just delete this class, so I don't have to keep fixing bugs in code that nobody uses or cares about.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en4 English -14 2021-08-24 22:14:34 363
en3 English -14 2021-08-24 20:53:53 4 Tiny change: 'ld anyone can tell me i' -> 'ld anyone tell me i'
en2 English -14 2021-08-24 20:52:13 4 Tiny change: 'ion/126903250) failed o' -> 'ion/126903561) failed o'
en1 English -14 2021-08-24 20:51:00 1273 Initial revision (published)