Skip to content

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);
			|            ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
Checklist

Merge request reports

Loading