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

src: ignore maybe-uninitialized warning string_search #31532

Closed
wants to merge 3 commits into from

Commits on Jan 27, 2020

  1. 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);
                ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
    
    The issue here seems to be with the `strategy_` field which is a pointer
    to a member function, and it is set in the constructor of StringSearch.
    It is always set and I've not been able to work around this warning
    so this commit suggests adding a pragma for GCC to ignore the warning.
    danbev committed Jan 27, 2020
    Configuration menu
    Copy the full SHA
    b520c74 View commit details
    Browse the repository at this point in the history

Commits on Feb 3, 2020

  1. Configuration menu
    Copy the full SHA
    1b3454d View commit details
    Browse the repository at this point in the history
  2. 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.
    danbev committed Feb 3, 2020
    Configuration menu
    Copy the full SHA
    b1269ab View commit details
    Browse the repository at this point in the history