memusage: Make fields of STL helper structs public #36869

pull hebasto wants to merge 1 commits into bitcoin:master from hebasto:261114-unused-private changing 1 files +0 −3
  1. hebasto commented at 12:07 PM on November 14, 2026: member

    The stl_tree_node, list_node and unordered_node class templates only mimic the layout of the standard library's container nodes, so that sizeof yields an estimate of the memory they use. Their fields are never accessed.

    Since llvm/llvm-project#237374, Clang 24 diagnoses these fields with -Wunused-private-field:

    $ cmake --build build
    [308/655] Building CXX object src/util/CMakeFiles/bitcoin_util.dir/__/logging.cpp.o
    In file included from ../src/logging.cpp:7:
    ../src/memusage.h:169:11: warning: private field 'ptr_next' is not used [-Wunused-private-field]
      169 |     void* ptr_next;
          |           ^
    ../src/memusage.h:170:11: warning: private field 'ptr_prev' is not used [-Wunused-private-field]
      170 |     void* ptr_prev;
          |           ^
    2 warnings generated.
    [355/655] Building CXX object src/CMakeFiles/bitcoin_node.dir/kernel/disconnected_transactions.cpp.o
    In file included from ../src/kernel/disconnected_transactions.cpp:8:
    In file included from ../src/core_memusage.h:10:
    ../src/memusage.h:184:11: warning: private field 'ptr' is not used [-Wunused-private-field]
      184 |     void* ptr;
          |           ^
    ../src/memusage.h:169:11: warning: private field 'ptr_next' is not used [-Wunused-private-field]
      169 |     void* ptr_next;
          |           ^
    ../src/memusage.h:170:11: warning: private field 'ptr_prev' is not used [-Wunused-private-field]
      170 |     void* ptr_prev;
          |           ^
    3 warnings generated.
    [424/655] Building CXX object src/CMakeFiles/bitcoin_node.dir/txgraph.cpp.o
    In file included from ../src/txgraph.cpp:7:
    In file included from ../src/cluster_linearize.h:17:
    ../src/memusage.h:72:9: warning: private field 'color' is not used [-Wunused-private-field]
       72 |     int color;
          |         ^
    ../src/memusage.h:73:11: warning: private field 'parent' is not used [-Wunused-private-field]
       73 |     void* parent;
          |           ^
    ../src/memusage.h:74:11: warning: private field 'left' is not used [-Wunused-private-field]
       74 |     void* left;
          |           ^
    ../src/memusage.h:75:11: warning: private field 'right' is not used [-Wunused-private-field]
       75 |     void* right;
          |           ^
    4 warnings generated.
    [425/655] Building CXX object src/CMakeFiles/bitcoin_node.dir/txmempool.cpp.o
    In file included from ../src/txmempool.cpp:6:
    In file included from ../src/txmempool.h:9:
    In file included from ../src/coins.h:11:
    In file included from ../src/core_memusage.h:10:
    ../src/memusage.h:72:9: warning: private field 'color' is not used [-Wunused-private-field]
       72 |     int color;
          |         ^
    ../src/memusage.h:73:11: warning: private field 'parent' is not used [-Wunused-private-field]
       73 |     void* parent;
          |           ^
    ../src/memusage.h:74:11: warning: private field 'left' is not used [-Wunused-private-field]
       74 |     void* left;
          |           ^
    ../src/memusage.h:75:11: warning: private field 'right' is not used [-Wunused-private-field]
       75 |     void* right;
          |           ^
    ../src/memusage.h:72:9: warning: private field 'color' is not used [-Wunused-private-field]
       72 |     int color;
          |         ^
    ../src/memusage.h:73:11: warning: private field 'parent' is not used [-Wunused-private-field]
       73 |     void* parent;
          |           ^
    ../src/memusage.h:74:11: warning: private field 'left' is not used [-Wunused-private-field]
       74 |     void* left;
          |           ^
    ../src/memusage.h:75:11: warning: private field 'right' is not used [-Wunused-private-field]
       75 |     void* right;
          |           ^
    ../src/memusage.h:72:9: warning: private field 'color' is not used [-Wunused-private-field]
       72 |     int color;
          |         ^
    ../src/memusage.h:73:11: warning: private field 'parent' is not used [-Wunused-private-field]
       73 |     void* parent;
          |           ^
    ../src/memusage.h:74:11: warning: private field 'left' is not used [-Wunused-private-field]
       74 |     void* left;
          |           ^
    ../src/memusage.h:75:11: warning: private field 'right' is not used [-Wunused-private-field]
       75 |     void* right;
          |           ^
    12 warnings generated.
    [535/655] Building CXX object src/test/CMakeFiles/test_bitcoin.dir/disconnected_transactions.cpp.o
    In file included from ../src/test/disconnected_transactions.cpp:6:
    In file included from ../src/core_memusage.h:10:
    ../src/memusage.h:184:11: warning: private field 'ptr' is not used [-Wunused-private-field]
      184 |     void* ptr;
          |           ^
    1 warning generated.
    [566/655] Building CXX object src/test/CMakeFiles/test_bitcoin.dir/pool_tests.cpp.o
    In file included from ../src/test/pool_tests.cpp:5:
    ../src/memusage.h:184:11: warning: private field 'ptr' is not used [-Wunused-private-field]
      184 |     void* ptr;
          |           ^
    1 warning generated.
    [655/655] Linking CXX executable bin/test_bitcoin
    

    This PR drops the private: access specifiers. It does not affect the size or alignment of the structs, as all their fields keep the same access control, and it is consistent with stl_shared_counter.

  2. memusage: Make fields of STL helper structs public
    The `stl_tree_node`, `list_node` and `unordered_node` class templates
    only mimic the layout of the standard library's container nodes, so
    that `sizeof` yields an estimate of the memory they use. Their fields
    are never accessed.
    
    Since llvm/llvm-project#237374, Clang 24 diagnoses these fields with
    `-Wunused-private-field`.
    
    This change drops the `private:` access specifiers. It does not affect
    the size or alignment of the structs, as all their fields keep the same
    access control, and it is consistent with `stl_shared_counter`.
    b9a6b0ca51
  3. DrahtBot commented at 12:07 PM on November 14, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process. A summary of reviews will appear here.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  4. hebasto referenced this in commit c282fc295e on Nov 14, 2026
Contributors

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: 2026-11-14 18:51 UTC

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