Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concerning compilation warning in string_search.h #37145

Closed
targos opened this issue Jan 30, 2021 · 0 comments
Closed

Concerning compilation warning in string_search.h #37145

targos opened this issue Jan 30, 2021 · 0 comments
Labels
c++ Issues and PRs that require attention from people who are familiar with C++.

Comments

@targos
Copy link
Member

targos commented Jan 30, 2021

On Windows with MSVC, the implementation of StringSearch<Char>::BoyerMooreHorspoolSearch emits a concerning warning.

Code:

node/src/string_search.h

Lines 459 to 461 in fd02dac

const size_t pattern_length = pattern_.length();
int* char_occurrences = bad_char_shift_table_;
int64_t badness = -pattern_length;

The emitted warning is C4146: unary minus operator applied to unsigned type, result still unsigned

This looks like it introduces a bug in the function, at least on Windows, because badness is never going to be a negative number.

@targos targos added the c++ Issues and PRs that require attention from people who are familiar with C++. label Jan 30, 2021
RaisinTen added a commit to RaisinTen/node that referenced this issue Jan 30, 2021
@jasnell jasnell closed this as completed in c148c3a Feb 4, 2021
danielleadams pushed a commit that referenced this issue Feb 16, 2021
Fixes: #37145

PR-URL: #37146
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Juan José Arboleda <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
targos pushed a commit that referenced this issue May 1, 2021
Fixes: #37145

PR-URL: #37146
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Juan José Arboleda <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant