[libcxx-commits] [PATCH] D121074: [libc++] Implement std::boyer_moore{, _horspool}_searcher
Adam Debreceni via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue May 17 00:10:30 PDT 2022
adamdebreceni added inline comments.
================
Comment at: libcxx/include/__functional/boyer_moore_searcher.h:208
+
+ vector<value_type> __scratch(__count);
+
----------------
ldionne wrote:
> adamdebreceni wrote:
> > philnik wrote:
> > > adamdebreceni wrote:
> > > > shouldn't this be `vector<difference_type>`?
> > > Why do you think it should be `vector<difference_type>`?
> > if `value_type` is `signed` and the range consists of e.g. the same values with length more than the max, `__compute_bm_prefix` will cause a signed overflow, moreover as `__scratch` can now contain negative values we could index out of `__suffix_`
> We should add a test and fix this bug in both this version and the `experimental/functional` version as well (even though we'll eventually remove that one).
if we plan on fixing the `expirmental/functional` we should add a `+1` to the size in the `_BMSkipTable` array-based specialization `typedef std::array<value_type, numeric_limits<unsigned_key_type>::max()> skip_map;` otherwise we could index out of the array (not an issue in the new one)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D121074/new/
https://reviews.llvm.org/D121074
More information about the libcxx-commits
mailing list