[-Wunsafe-buffer-usage] Warn about two-arg string view constructors
#166.644 aberto em 5 de nov. de 2025
Métricas do repositório
- Stars
- (26.378 stars)
- Métricas de merge de PR
- (Mesclagem média 1d 2h) (1.000 fundiu PRs em 30d)
Description
The two-arg form of std::span<> will currently produce a warning when used along with the -Wunsafe-buffer-usage-in-container option, subject to heuristics that try to determine suspicious arguments.
The string view types, (actually std::basic_string_view<>) have the same issues as does std::span<> when used with a two-argument constructor.
Since the name of the -W flag says "container", I humbly propose covering this case under the same warning, and produce the same waring when encountered.
A small task is removing the specific mention of std::span<> from the diagnostic, expanding it to imply other containers.