Incredible bug found in __gnu_cxx::rope

Revision en3, by -14, 2021-08-24 20:53:53

Today when I took part in the Round #740 solving problem D. Top-Notch Insertions, my submission 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:

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!

Tags bug, __gnu_cxx::rope

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)