diff options
-rw-r--r-- | AK/StringView.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/AK/StringView.h b/AK/StringView.h index 17f0623f8c..f75786bc70 100644 --- a/AK/StringView.h +++ b/AK/StringView.h @@ -62,7 +62,12 @@ public: [[nodiscard]] ReadonlyBytes bytes() const { return { m_characters, m_length }; } - constexpr char const& operator[](size_t index) const { return m_characters[index]; } + constexpr char const& operator[](size_t index) const + { + if (!is_constant_evaluated()) + VERIFY(index < m_length); + return m_characters[index]; + } using ConstIterator = SimpleIterator<const StringView, char const>; |