Skip to content
Closed
Changes from all commits
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
src: fix StringSearch compiler warning
StringSearchBase has tables (int array members) that are used only for
some search strategies, but g++-9 (at least) doesn't understand when
they will or will not be used. Default-initialize them in the
constructor to avoid this warning:

	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]
		113 |     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]
		113 |     return (this->*strategy_)(subject, index);
				|            ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
  • Loading branch information
sam-github committed Feb 14, 2020
commit 9697fac5e11a7ba19b2b1888eb568b0c6b6a2409
3 changes: 3 additions & 0 deletions src/string_search.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ class Vector {
// independently of subject and pattern char size.
class StringSearchBase {
protected:
StringSearchBase() : bad_char_shift_table_(), good_suffix_shift_table_(),
suffix_table_() {}

// Cap on the maximal shift in the Boyer-Moore implementation. By setting a
// limit, we can fix the size of tables. For a needle longer than this limit,
// search will not be optimal, since we only build tables for a suffix
Expand Down