[libcxx-commits] [libcxx] [libc++] Remove assertions from <string_view> that are unreachable (PR #148598)

Konstantin Varlamov via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jul 31 18:57:19 PDT 2025


var-const wrote:

Thanks for pinging! Sorry I'm just now getting to this.

@ldionne I believe the issues you probably have in mind were in `span`'s constructor, not `string_view`.

@philnik777 It's not _100%_ true that these are unreachable: https://godbolt.org/z/7sxTez18q. I can't recall why the constructor check is not enabled in the C++11 mode (it _seems_ to ring a very vague bell, but maybe I'm confusing it with something). Doing a little archaeology, it seems like it was that way from the [very first implementation](https://github.com/llvm/llvm-project/blob/053d81ceebe9a54255c49801b88ab61b5d03060a/libcxx/include/string_view) by Marshal. @ldionne Do you have any recollection on this, perhaps?

I'd be on board with removing the version check in the constructor's assertion (assuming there's no good reason to keep it, at least now) which will clear the way for the change in this patch. But perhaps there's a reason to keep the version check?

https://github.com/llvm/llvm-project/pull/148598


More information about the libcxx-commits mailing list