refactor, 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.

    Type Reviewers
    ACK maflcko, l0rinc

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  4. hebasto referenced this in commit c282fc295e on Nov 14, 2026
  5. maflcko commented at 8:09 AM on November 16, 2026: member

    lgtm ACK b9a6b0ca51801e95956b7d5307d5b198b9fb7d3f

    Forgot refactor prefix in pull title?

  6. l0rinc approved
  7. l0rinc commented at 8:24 AM on November 16, 2026: contributor

    ACK b9a6b0ca51801e95956b7d5307d5b198b9fb7d3f

    Nit: could also drop the unordered_node inheritance private (or use class with a public ptr) if we're already touching it.

  8. hebasto renamed this:
    memusage: Make fields of STL helper structs public
    refactor, memusage: Make fields of STL helper structs public
    on Nov 16, 2026
  9. hebasto commented at 1:20 PM on November 16, 2026: member

    Nit: could also drop the unordered_node inheritance private (or use class with a public ptr) if we're already touching it.

    I'll take this suggestion if I need to update the branch.

  10. fanquake merged this on Nov 16, 2026
  11. fanquake closed this on Nov 16, 2026

  12. fanquake added the label Needs Backport (32.x) on Nov 16, 2026
  13. hebasto deleted the branch on Nov 16, 2026
  14. fanquake referenced this in commit 02881236d6 on Nov 16, 2026
  15. fanquake removed the label Needs Backport (32.x) on Nov 16, 2026
  16. fanquake added the label Needs backport (30.x) on Nov 16, 2026
  17. fanquake added the label Needs Backport (31.x) on Nov 16, 2026
  18. fanquake commented at 6:37 PM on November 16, 2026: member

    Backported to 32.x in #36727.

  19. fanquake commented at 4:14 PM on November 17, 2026: member

    Backported to 31.x in #36901.

  20. fanquake removed the label Needs Backport (31.x) on Nov 17, 2026
  21. fanquake removed the label Needs backport (30.x) on Nov 17, 2026
  22. fanquake commented at 4:25 PM on November 17, 2026: member

    Backported to 30.x in #36902.


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-12-05 03:51 UTC

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