many warnings: declaration of ‘what’ shadows a member of ’this’ when building #10080

issue dooglus openend this issue on March 26, 2017
  1. dooglus commented at 4:22 am on March 26, 2017: contributor

    Attempting to build from the current master branch (commit 111849345bb5140f86b48e730ceab4bff45fa2e9) with gcc version 4.9.2 (Debian 4.9.2-10) I see a lot of warning messages:

      CXX      bitcoind-bitcoind.o
    In file included from util.h:18:0,
                     from bitcoind.cpp:17:
    tinyformat.h: In constructor ‘tinyformat::format_error::format_error(const string&)’:
    tinyformat.h:170:42: warning: declaration of ‘what’ shadows a member of 'this' [-Wshadow]
         format_error(const std::string &what): std::runtime_error(what) {
                                              ^
      CXX      libbitcoin_server_a-addrman.o
    In file included from util.h:18:0,
                     from addrman.h:14,
                     from addrman.cpp:6:
    tinyformat.h: In constructor ‘tinyformat::format_error::format_error(const string&)’:
    tinyformat.h:170:42: warning: declaration of ‘what’ shadows a member of 'this' [-Wshadow]
         format_error(const std::string &what): std::runtime_error(what) {
                                              ^
      CXX      libbitcoin_server_a-addrdb.o
    In file included from util.h:18:0,
                     from addrman.h:14,
                     from addrdb.cpp:8:
    tinyformat.h: In constructor ‘tinyformat::format_error::format_error(const string&)’:
    tinyformat.h:170:42: warning: declaration of ‘what’ shadows a member of 'this' [-Wshadow]
         format_error(const std::string &what): std::runtime_error(what) {
                                              ^
    

    This appears to have been recently introduced by https://github.com/bitcoin/bitcoin/commit/b651270c. A fix would seem to be something like this:

    diff --git a/src/tinyformat.h b/src/tinyformat.h
    index 5022d46..df128f1 100644
    --- a/src/tinyformat.h
    +++ b/src/tinyformat.h
    @@ -167,7 +167,7 @@ namespace tinyformat {
     class format_error: public std::runtime_error
     {
     public:
    -    format_error(const std::string &what): std::runtime_error(what) {
    +    format_error(const std::string &_what): std::runtime_error(_what) {
         }
     };
    
  2. paveljanik commented at 4:55 am on March 26, 2017: contributor
    Can you please PR the fix? Please use fmterr as it is used in src/util.h.
  3. dooglus referenced this in commit c8b6cc77bd on Mar 26, 2017
  4. fanquake added the label Refactoring on Mar 30, 2017
  5. laanwj commented at 10:13 am on April 2, 2017: member
    Closing as wshadow has been disabled.
  6. laanwj closed this on Apr 2, 2017

  7. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-19 03:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me