[Bug tree-optimization/117279] std::string bounds check from -D_GLIBCXX_ASSERTIONS not optimised out
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Nov 18 22:19:33 GMT 2025
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117279
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I have a simple libstdc++ patch which removes the bounds checks for this
though:
```
#include <string.h>
char t;
std::string foo(int index, std::string rrr) {
if (index < 0 || index > 4) {
return 0;
}
std::string p = std::string{"AAA "} + rrr;
t = p[index];
return p;
}
```
More information about the Gcc-bugs
mailing list