https://github.com/zeyi2 commented:

It may be nice to add notes about boundary safety in the documentation.

-----

https://en.cppreference.com/w/cpp/string/basic_string_view/remove_suffix.html

>  If n > size() is true, the behavior is undefined.

If I understand the current implementation correctly, we may have fixes like:

```cpp
std::string_view sv = "Hi";
size_t n = 5;
sv = sv.substr(0, sv.size() - n);

// ->
// sv.remove_suffix(n); // UB
```

https://github.com/llvm/llvm-project/pull/120055
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to