`<string>`: `basic_string`'s erasing operations don't orphan iterators
Los mantenedores suelen responder en 2 días
@frederick-vs-ja ya está trabajando en esto.
Desde el 23/11/2026.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 57/100
Línea de trabajo
Start by comparing basic_string iterator handling for pop_back, erase, and clear with vector's behavior in the MSVC STL. Use the command-line test case with _ITERATOR_DEBUG_LEVEL == 2 and -std:c++20 -D_DEBUG to check the reported gap. Done means erasing operations diagnose invalidated iterators in both compile-time and run-time debug checks, as described.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the bug
As discovered by Copilot in https://github.com/microsoft/STL/pull/6500#discussion_r4377205703, MSVC STL's basic_string seems to lack iterator orphaning in erasing operations (pop_back, erase, and clear).
It's unclear to me whether this is by design. At least the status of basic_string is inconsistent with vector.
Command-line test case
#include <cassert>
#include <string>
#include <vector>
#if _ITERATOR_DEBUG_LEVEL != 2
#error
#endif // _ITERATOR_DEBUG_LEVEL != 2
constexpr bool test_string() {
auto s = std::string{"The quick brown fox jumps over the lazy dog"};
auto it = s.cbegin();
auto jt = s.cbegin() + 10;
s.erase(it + 5);
return it == jt - 10;
}
static_assert(test_string()); // not diagnosed when _ITERATOR_DEBUG_LEVEL == 2
constexpr bool test_vector() {
auto v = std::vector{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
auto it = v.cbegin();
auto jt = v.cbegin() + 10;
v.erase(it + 5);
return it == jt - 10;
}
static_assert(test_vector()); // diagnosed when _ITERATOR_DEBUG_LEVEL == 2
Godbolt link, using -std:c++20 -D_DEBUG.
Expected behavior
test_string() also fails in debug modes, in both compile time and run time.
STL version
Latest https://github.com/microsoft/STL/commit/b6f01e438b68ee497f9c08313e49d12bb2f0d8e0.
(For the online example, probably https://github.com/microsoft/STL/commit/edd1486e5fe753616b6fd3695da96f352b4092d2.)
Additional context
- Lenguaje dominante
- C++
- Estrellas
- 11.2k
- Forks
- 1.7k
- Merge medio
- 4 d 4 h
- PR fusionados (30 d)
- 14
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de microsoft/STL
-
LWG
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 2 días
-
generator LWG
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 2 días
-
LWG
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 2 días
-
`<__msvc_math.hpp>`: `_USE_MATH_DEFINES` is ignored after the first `<math.h>` include under `/Zc:cmath`Posiblemente ocupada @tiagomacarios la tomó hace 10 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 2 días
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 2 días
Todos los issues de microsoft/STL
Issues similares
-
c++ easy first-contributor first-contributors good first issue help wanted up-for-grabs
Dificultad 1/5 1-3 horas Aptitud para principiantes 94/100
fork-commit-merge/fork-commit-merge#8709 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
-
Type: Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 1 día
-
bug data-types
Dificultad 2/5 1-3 horas Aptitud para principiantes 71/100
ClickHouse/clickhouse-odbc#680 ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
ionut-mihalache/aqua#31 · 1 comentario ·