https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112314
--- Comment #5 from Jose Dapena Paz <jdapena at igalia dot com> --- (In reply to Jonathan Wakely from comment #4) > (In reply to Jose Dapena Paz from comment #2) > > In any case, the failing test is actually passing -1, my understanding is > > that that one should always assert no matter what we are passing as const > > char*. > > Yes but I'm not going to add a check for -1 just to make some unit test > pass. In real code (size_t)-2 or (size_t)(-some other value) is at least as > likely. > > __glibcxx_assert(not in chromium tests) doesn't seem useful. Oh, I just checked the LLVM implementation and it is... interesting: https://github.com/llvm/llvm-project/blob/main/libcxx/include/string_view#L311C1-L318C1 It checks two conditions: - Length should be 0 OR pointer should not be null. - The length is less than the possible pointer difference (checked with numeric_limits).