https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112314
Bug ID: 112314 Summary: Missing index assertions in basic_string_view Product: gcc Version: 12.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: jdapena at igalia dot com Target Milestone: --- While testing Chromium base unit tests with _GLIBCXX_ASSERTIONS=1, that include checks for base::StringPiece, that wraps nowadays std::string_view, two unit tests are failing because they are expected to assert and they don't. One failing tests is: { StringPiece piece; ASSERT_DEATH_IF_SUPPORTED(piece.remove_suffix(1), ""); } In this case, std::basic_string_view::remove_suffix should check if the index provided is valid. Another failing test is: int length = -1; ASSERT_DEATH_IF_SUPPORTED({ StringPiece piece("hello", length); }, ""); In this case, std::basic_string_view::basic_string_view(const _CharT* __str, size_type __len) is not validating that __len is a valid index for __str.