Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
src: ignore maybe-uninitialized warning string_search
Currently, the following compilation warning is generated with GCC
version 8.2.1:

In file included from ../src/node_buffer.cc:29:
../src/string_search.h:
In function ‘size_t node::stringsearch::SearchString(
    node::stringsearch::Vector<const Char>,
    node::stringsearch::Vector<const Char>,
    size_t) [with Char = short unsigned int]’:
../src/string_search.h:113:30: warning:
‘search’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
     return (this->*strategy_)(subject, index);
            ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~

../src/string_search.h:
In function ‘size_t node::stringsearch::SearchString(
    node::stringsearch::Vector<const Char>,
    node::stringsearch::Vector<const Char>,
    size_t) [with Char = unsigned char]’:
../src/string_search.h:113:30:
warning: ‘search’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
     return (this->*strategy_)(subject, index);
            ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~

I'm not sure why this works but delegating to the default constructor of
the base class StringSearchBase makes this warning go away.
  • Loading branch information
danbev committed Feb 3, 2020
commit b1269abf1a05287347fe09212edc08ee8a8f6be5
2 changes: 1 addition & 1 deletion src/string_search.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class StringSearch : private StringSearchBase {
typedef stringsearch::Vector<const Char> Vector;

explicit StringSearch(Vector pattern)
: pattern_(pattern), start_(0) {
: StringSearchBase(), pattern_(pattern), start_(0) {
if (pattern.length() >= kBMMaxShift) {
start_ = pattern.length() - kBMMaxShift;
}
Expand Down