Bug: Last elements in basic_charset
initialization are discarded
#200
Labels
bug
Something isn't working
basic_charset
initialization are discarded
#200
Describe the bug
When initializing a
basic_charset
with character arrays such as those returned bydigits()
and others, the last element of the array is incorrectly discarded.StringZilla/include/stringzilla/stringzilla.hpp
Lines 192 to 195 in 152ed04
This is due to the use of
count_characters - 1
in the loop that populates thebasic_charset
bitset.StringZilla/include/stringzilla/stringzilla.hpp
Lines 283 to 289 in 152ed04
While this prevents including a null terminator for string literals like
sz::char_set("x")
, it causes incorrect behavior when handling character arrays that do not have a null terminator, resulting in the exclusion of the final character.I believe this local block is the full extent of the affected code.
StringZilla/include/stringzilla/stringzilla.hpp
Lines 330 to 341 in 152ed04
Steps to reproduce
Expected behavior
No asserts
StringZilla version
v3.11.0
Operating System
Ubuntu 22.04.5
Hardware architecture
x86
Which interface are you using?
C++ bindings
Contact Details
No response
Are you open to being tagged as a contributor?
.git
history as a contributorIs there an existing issue for this?
Code of Conduct
The text was updated successfully, but these errors were encountered: