refactor: Use aliasing shared_ptr in Sock::Wait #34471

pull maflcko wants to merge 1 commits into bitcoin:master from maflcko:2602-refactor-alias-shptr changing 1 files +5 −3
  1. maflcko commented at 6:37 pm on February 1, 2026: member

    Currently, a no-op lambda is used as the deleter for the temporary shared pointer helper in Sock::Wait. This is perfectly fine, but has a few style issues:

    Fix all issues by just using an aliasing shared pointer, which points to this, but is otherwise empty (sits on the stack without any heap allocations).

  2. DrahtBot added the label Refactoring on Feb 1, 2026
  3. DrahtBot commented at 6:38 pm on February 1, 2026: contributor

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

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK hodlinator

    If your review is incorrectly listed, please copy-paste <!–meta-tag:bot-skip–> into the comment that the bot should ignore.

  4. maflcko commented at 6:41 pm on February 1, 2026: member

    If someone wants to reproduce the GCC-16 warning on a fresh install of Fedora 43:

    0dnf install -y git cmake pkgconfig boost-devel libevent-devel sqlite-devel capnproto capnproto-devel zeromq-devel ccache qt6-qttools-devel qt6-qtbase-devel qrencode-devel systemtap-sdt-devel python3-zmq libstdc++
    1
    2dnf -y copr enable jwakely/gcc-latest && dnf -y install gcc-latest
    3
    4git clone https://github.com/bitcoin/bitcoin.git  --depth=1 ./b-c && cd b-c
    5
    6rm -rf ./bld/ && cmake -B bld -DCMAKE_C_COMPILER="/opt/gcc-latest/bin/gcc" -DCMAKE_CXX_COMPILER="/opt/gcc-latest/bin/g++;-static-libstdc++" --preset=dev-mode
    7
    8cmake --build ./bld -j $(nproc)
    

    Will print:

     0[ 13%] Building CXX object src/util/CMakeFiles/bitcoin_util.dir/sock.cpp.o
     1In file included from /opt/gcc-latest/include/c++/16.0.1/bits/stl_iterator.h:78,
     2                 from /opt/gcc-latest/include/c++/16.0.1/bits/stl_algobase.h:66,
     3                 from /opt/gcc-latest/include/c++/16.0.1/bits/stl_algo.h:60,
     4                 from /opt/gcc-latest/include/c++/16.0.1/chrono:57,
     5                 from /b-c/src/util/time.h:9,
     6                 from /b-c/src/common/system.h:10,
     7                 from /b-c/src/util/sock.cpp:5:
     8In function constexpr void std::destroy_at(_Tp*) [with _Tp = mutex],
     9    inlined from constexpr void std::_Destroy(_Tp*) [with _Tp = mutex] at /opt/gcc-latest/include/c++/16.0.1/bits/stl_construct.h:164:22,
    10    inlined from static constexpr void std::allocator_traits<std::allocator<void> >::destroy(allocator_type&, _Up*) [with _Up = std::mutex] at /opt/gcc-latest/include/c++/16.0.1/bits/alloc_traits.h:819:17,
    11    inlined from void std::_Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp>::_M_dispose() [with _Tp = std::mutex; _Alloc = std::allocator<void>; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic] at /opt/gcc-latest/include/c++/16.0.1/bits/shared_ptr_base.h:675:35,
    12    inlined from void std::_Sp_counted_base<_Lp>::_M_release() [with __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic] at /opt/gcc-latest/include/c++/16.0.1/bits/shared_ptr_base.h:423:18,
    13    inlined from void std::_Sp_counted_base<_Lp>::_M_release() [with __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic] at /opt/gcc-latest/include/c++/16.0.1/bits/shared_ptr_base.h:392:5,
    14    inlined from std::__shared_count<_Lp>::~__shared_count() [with __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic] at /opt/gcc-latest/include/c++/16.0.1/bits/shared_ptr_base.h:1129:21,
    15    inlined from std::__shared_ptr<_Tp, _Lp>::~__shared_ptr() [with _Tp = const Sock; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic] at /opt/gcc-latest/include/c++/16.0.1/bits/shared_ptr_base.h:1603:7,
    16    inlined from std::shared_ptr<const Sock>::~shared_ptr() at /opt/gcc-latest/include/c++/16.0.1/bits/shared_ptr.h:175:11,
    17    inlined from virtual bool Sock::Wait(std::chrono::milliseconds, Event, Event*) const at /b-c/src/util/sock.cpp:157:1:
    18/opt/gcc-latest/include/c++/16.0.1/bits/stl_construct.h:88:9: warning: array subscript std::mutex[0] is partly outside array bounds of unsigned char [24] [-Warray-bounds=]
    19   88 |         __location->~_Tp();
    20      |         ^~~~~~~~~~
    21In file included from /opt/gcc-latest/include/c++/16.0.1/x86_64-pc-linux-gnu/bits/c++allocator.h:33,
    22                 from /opt/gcc-latest/include/c++/16.0.1/bits/allocator.h:46,
    23                 from /opt/gcc-latest/include/c++/16.0.1/string:46,
    24                 from /opt/gcc-latest/include/c++/16.0.1/bits/locale_classes.h:43,
    25                 from /opt/gcc-latest/include/c++/16.0.1/bits/ios_base.h:43,
    26                 from /opt/gcc-latest/include/c++/16.0.1/ios:46,
    27                 from /opt/gcc-latest/include/c++/16.0.1/istream:42,
    28                 from /opt/gcc-latest/include/c++/16.0.1/sstream:42,
    29                 from /opt/gcc-latest/include/c++/16.0.1/chrono:61:
    30In member function _Tp* std::__new_allocator<_Tp>::allocate(size_type, const void*) [with _Tp = std::_Sp_counted_deleter<const Sock*, Sock::Wait(std::chrono::milliseconds, Event, Event*) const::<lambda(const Sock*)>, std::allocator<void>, __gnu_cxx::_S_atomic>],
    31    inlined from constexpr _Tp* std::allocator< <template-parameter-1-1> >::allocate(std::size_t) [with _Tp = std::_Sp_counted_deleter<const Sock*, Sock::Wait(std::chrono::milliseconds, Event, Event*) const::<lambda(const Sock*)>, std::allocator<void>, __gnu_cxx::_S_atomic>] at /opt/gcc-latest/include/c++/16.0.1/bits/allocator.h:203:40,
    32    inlined from static constexpr _Tp* std::allocator_traits<std::allocator<_CharT> >::allocate(allocator_type&, size_type) [with _Tp = std::_Sp_counted_deleter<const Sock*, Sock::Wait(std::chrono::milliseconds, Event, Event*) const::<lambda(const Sock*)>, std::allocator<void>, __gnu_cxx::_S_atomic>] at /opt/gcc-latest/include/c++/16.0.1/bits/alloc_traits.h:614:28,
    33    inlined from std::__allocated_ptr<_Alloc> std::__allocate_guarded(_Alloc&) [with _Alloc = allocator<_Sp_counted_deleter<const Sock*, Sock::Wait(std::chrono::milliseconds, Event, Event*) const::<lambda(const Sock*)>, allocator<void>, __gnu_cxx::_S_atomic> >] at /opt/gcc-latest/include/c++/16.0.1/bits/allocated_ptr.h:103:69,
    34    inlined from std::__shared_count<_Lp>::__shared_count(_Ptr, _Deleter, _Alloc) [with _Ptr = const Sock*; _Deleter = Sock::Wait(std::chrono::milliseconds, Event, Event*) const::<lambda(const Sock*)>; _Alloc = std::allocator<void>; <template-parameter-2-4> = void; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic] at /opt/gcc-latest/include/c++/16.0.1/bits/shared_ptr_base.h:1007:13,
    35    inlined from std::__shared_count<_Lp>::__shared_count(_Ptr, _Deleter) [with _Ptr = const Sock*; _Deleter = Sock::Wait(std::chrono::milliseconds, Event, Event*) const::<lambda(const Sock*)>; <template-parameter-2-3> = void; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic] at /opt/gcc-latest/include/c++/16.0.1/bits/shared_ptr_base.h:996:57,
    36    inlined from std::__shared_ptr<_Tp, _Lp>::__shared_ptr(_Yp*, _Deleter) [with _Yp = const Sock; _Deleter = Sock::Wait(std::chrono::milliseconds, Event, Event*) const::<lambda(const Sock*)>; <template-parameter-2-3> = void; _Tp = const Sock; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic] at /opt/gcc-latest/include/c++/16.0.1/bits/shared_ptr_base.h:1557:17,
    37    inlined from std::shared_ptr<_Tp>::shared_ptr(_Yp*, _Deleter) [with _Yp = const Sock; _Deleter = Sock::Wait(std::chrono::milliseconds, Event, Event*) const::<lambda(const Sock*)>; <template-parameter-2-3> = void; _Tp = const Sock] at /opt/gcc-latest/include/c++/16.0.1/bits/shared_ptr.h:231:48,
    38    inlined from virtual bool Sock::Wait(std::chrono::milliseconds, Event, Event*) const at /b-c/src/util/sock.cpp:144:64:
    39/opt/gcc-latest/include/c++/16.0.1/bits/new_allocator.h:151:73: note: at offset 16 into object of size 24 allocated by operator new
    40  151 |         return static_cast<_Tp*>(_GLIBCXX_OPERATOR_NEW(__n * sizeof(_Tp)));
    41      |                                                                         ^
    42In file included from /opt/gcc-latest/include/c++/16.0.1/bits/shared_ptr.h:53,
    43                 from /opt/gcc-latest/include/c++/16.0.1/chrono:64:
    44In destructor std::_Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp>::~_Sp_counted_ptr_inplace() [with _Tp = std::mutex; _Alloc = std::allocator<void>; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic],
    45    inlined from std::_Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp>::~_Sp_counted_ptr_inplace() [with _Tp = std::mutex; _Alloc = std::allocator<void>; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic] at /opt/gcc-latest/include/c++/16.0.1/bits/shared_ptr_base.h:670:45,
    46    inlined from void std::_Sp_counted_base<_Lp>::_M_destroy() [with __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic] at /opt/gcc-latest/include/c++/16.0.1/bits/shared_ptr_base.h:143:9,
    47    inlined from void std::_Sp_counted_base<_Lp>::_M_release() [with __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic] at /opt/gcc-latest/include/c++/16.0.1/bits/shared_ptr_base.h:424:18,
    48    inlined from void std::_Sp_counted_base<_Lp>::_M_release() [with __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic] at /opt/gcc-latest/include/c++/16.0.1/bits/shared_ptr_base.h:392:5,
    49    inlined from std::__shared_count<_Lp>::~__shared_count() [with __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic] at /opt/gcc-latest/include/c++/16.0.1/bits/shared_ptr_base.h:1129:21,
    50    inlined from std::__shared_ptr<_Tp, _Lp>::~__shared_ptr() [with _Tp = const Sock; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic] at /opt/gcc-latest/include/c++/16.0.1/bits/shared_ptr_base.h:1603:7,
    51    inlined from std::shared_ptr<const Sock>::~shared_ptr() at /opt/gcc-latest/include/c++/16.0.1/bits/shared_ptr.h:175:11,
    52    inlined from virtual bool Sock::Wait(std::chrono::milliseconds, Event, Event*) const at /b-c/src/util/sock.cpp:157:1:
    53/opt/gcc-latest/include/c++/16.0.1/bits/shared_ptr_base.h:670:45: warning: array subscript std::_Sp_counted_ptr_inplace<std::mutex, std::allocator<void>, __gnu_cxx::_S_atomic>[0] is partly outside array bounds of unsigned char [24] [-Warray-bounds=]
    54  670 |       ~_Sp_counted_ptr_inplace() noexcept { }
    55      |                                             ^
    56In member function _Tp* std::__new_allocator<_Tp>::allocate(size_type, const void*) [with _Tp = std::_Sp_counted_deleter<const Sock*, Sock::Wait(std::chrono::milliseconds, Event, Event*) const::<lambda(const Sock*)>, std::allocator<void>, __gnu_cxx::_S_atomic>],
    57    inlined from constexpr _Tp* std::allocator< <template-parameter-1-1> >::allocate(std::size_t) [with _Tp = std::_Sp_counted_deleter<const Sock*, Sock::Wait(std::chrono::milliseconds, Event, Event*) const::<lambda(const Sock*)>, std::allocator<void>, __gnu_cxx::_S_atomic>] at /opt/gcc-latest/include/c++/16.0.1/bits/allocator.h:203:40,
    58    inlined from static constexpr _Tp* std::allocator_traits<std::allocator<_CharT> >::allocate(allocator_type&, size_type) [with _Tp = std::_Sp_counted_deleter<const Sock*, Sock::Wait(std::chrono::milliseconds, Event, Event*) const::<lambda(const Sock*)>, std::allocator<void>, __gnu_cxx::_S_atomic>] at /opt/gcc-latest/include/c++/16.0.1/bits/alloc_traits.h:614:28,
    59    inlined from std::__allocated_ptr<_Alloc> std::__allocate_guarded(_Alloc&) [with _Alloc = allocator<_Sp_counted_deleter<const Sock*, Sock::Wait(std::chrono::milliseconds, Event, Event*) const::<lambda(const Sock*)>, allocator<void>, __gnu_cxx::_S_atomic> >] at /opt/gcc-latest/include/c++/16.0.1/bits/allocated_ptr.h:103:69,
    60    inlined from std::__shared_count<_Lp>::__shared_count(_Ptr, _Deleter, _Alloc) [with _Ptr = const Sock*; _Deleter = Sock::Wait(std::chrono::milliseconds, Event, Event*) const::<lambda(const Sock*)>; _Alloc = std::allocator<void>; <template-parameter-2-4> = void; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic] at /opt/gcc-latest/include/c++/16.0.1/bits/shared_ptr_base.h:1007:13,
    61    inlined from std::__shared_count<_Lp>::__shared_count(_Ptr, _Deleter) [with _Ptr = const Sock*; _Deleter = Sock::Wait(std::chrono::milliseconds, Event, Event*) const::<lambda(const Sock*)>; <template-parameter-2-3> = void; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic] at /opt/gcc-latest/include/c++/16.0.1/bits/shared_ptr_base.h:996:57,
    62    inlined from std::__shared_ptr<_Tp, _Lp>::__shared_ptr(_Yp*, _Deleter) [with _Yp = const Sock; _Deleter = Sock::Wait(std::chrono::milliseconds, Event, Event*) const::<lambda(const Sock*)>; <template-parameter-2-3> = void; _Tp = const Sock; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic] at /opt/gcc-latest/include/c++/16.0.1/bits/shared_ptr_base.h:1557:17,
    63    inlined from std::shared_ptr<_Tp>::shared_ptr(_Yp*, _Deleter) [with _Yp = const Sock; _Deleter = Sock::Wait(std::chrono::milliseconds, Event, Event*) const::<lambda(const Sock*)>; <template-parameter-2-3> = void; _Tp = const Sock] at /opt/gcc-latest/include/c++/16.0.1/bits/shared_ptr.h:231:48,
    64    inlined from virtual bool Sock::Wait(std::chrono::milliseconds, Event, Event*) const at /b-c/src/util/sock.cpp:144:64:
    65/opt/gcc-latest/include/c++/16.0.1/bits/new_allocator.h:151:73: note: object of size 24 allocated by operator new
    66  151 |         return static_cast<_Tp*>(_GLIBCXX_OPERATOR_NEW(__n * sizeof(_Tp)));
    67      |                                                                         ^
    68In destructor std::_Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp>::~_Sp_counted_ptr_inplace() [with _Tp = std::mutex; _Alloc = std::allocator<void>; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic],
    69    inlined from void std::_Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp>::_M_destroy() [with _Tp = std::mutex; _Alloc = std::allocator<void>; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic] at /opt/gcc-latest/include/c++/16.0.1/bits/shared_ptr_base.h:684:32,
    70    inlined from void std::_Sp_counted_base<_Lp>::_M_release() [with __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic] at /opt/gcc-latest/include/c++/16.0.1/bits/shared_ptr_base.h:424:18,
    71    inlined from void std::_Sp_counted_base<_Lp>::_M_release() [with __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic] at /opt/gcc-latest/include/c++/16.0.1/bits/shared_ptr_base.h:392:5,
    72    inlined from std::__shared_count<_Lp>::~__shared_count() [with __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic] at /opt/gcc-latest/include/c++/16.0.1/bits/shared_ptr_base.h:1129:21,
    73    inlined from std::__shared_ptr<_Tp, _Lp>::~__shared_ptr() [with _Tp = const Sock; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic] at /opt/gcc-latest/include/c++/16.0.1/bits/shared_ptr_base.h:1603:7,
    74    inlined from std::shared_ptr<const Sock>::~shared_ptr() at /opt/gcc-latest/include/c++/16.0.1/bits/shared_ptr.h:175:11,
    75    inlined from virtual bool Sock::Wait(std::chrono::milliseconds, Event, Event*) const at /b-c/src/util/sock.cpp:157:1:
    76/opt/gcc-latest/include/c++/16.0.1/bits/shared_ptr_base.h:670:45: warning: array subscript std::_Sp_counted_ptr_inplace<std::mutex, std::allocator<void>, __gnu_cxx::_S_atomic>[0] is partly outside array bounds of unsigned char [24] [-Warray-bounds=]
    77  670 |       ~_Sp_counted_ptr_inplace() noexcept { }
    78      |                                             ^
    79In member function _Tp* std::__new_allocator<_Tp>::allocate(size_type, const void*) [with _Tp = std::_Sp_counted_deleter<const Sock*, Sock::Wait(std::chrono::milliseconds, Event, Event*) const::<lambda(const Sock*)>, std::allocator<void>, __gnu_cxx::_S_atomic>],
    80    inlined from constexpr _Tp* std::allocator< <template-parameter-1-1> >::allocate(std::size_t) [with _Tp = std::_Sp_counted_deleter<const Sock*, Sock::Wait(std::chrono::milliseconds, Event, Event*) const::<lambda(const Sock*)>, std::allocator<void>, __gnu_cxx::_S_atomic>] at /opt/gcc-latest/include/c++/16.0.1/bits/allocator.h:203:40,
    81    inlined from static constexpr _Tp* std::allocator_traits<std::allocator<_CharT> >::allocate(allocator_type&, size_type) [with _Tp = std::_Sp_counted_deleter<const Sock*, Sock::Wait(std::chrono::milliseconds, Event, Event*) const::<lambda(const Sock*)>, std::allocator<void>, __gnu_cxx::_S_atomic>] at /opt/gcc-latest/include/c++/16.0.1/bits/alloc_traits.h:614:28,
    82    inlined from std::__allocated_ptr<_Alloc> std::__allocate_guarded(_Alloc&) [with _Alloc = allocator<_Sp_counted_deleter<const Sock*, Sock::Wait(std::chrono::milliseconds, Event, Event*) const::<lambda(const Sock*)>, allocator<void>, __gnu_cxx::_S_atomic> >] at /opt/gcc-latest/include/c++/16.0.1/bits/allocated_ptr.h:103:69,
    83    inlined from std::__shared_count<_Lp>::__shared_count(_Ptr, _Deleter, _Alloc) [with _Ptr = const Sock*; _Deleter = Sock::Wait(std::chrono::milliseconds, Event, Event*) const::<lambda(const Sock*)>; _Alloc = std::allocator<void>; <template-parameter-2-4> = void; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic] at /opt/gcc-latest/include/c++/16.0.1/bits/shared_ptr_base.h:1007:13,
    84    inlined from std::__shared_count<_Lp>::__shared_count(_Ptr, _Deleter) [with _Ptr = const Sock*; _Deleter = Sock::Wait(std::chrono::milliseconds, Event, Event*) const::<lambda(const Sock*)>; <template-parameter-2-3> = void; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic] at /opt/gcc-latest/include/c++/16.0.1/bits/shared_ptr_base.h:996:57,
    85    inlined from std::__shared_ptr<_Tp, _Lp>::__shared_ptr(_Yp*, _Deleter) [with _Yp = const Sock; _Deleter = Sock::Wait(std::chrono::milliseconds, Event, Event*) const::<lambda(const Sock*)>; <template-parameter-2-3> = void; _Tp = const Sock; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic] at /opt/gcc-latest/include/c++/16.0.1/bits/shared_ptr_base.h:1557:17,
    86    inlined from std::shared_ptr<_Tp>::shared_ptr(_Yp*, _Deleter) [with _Yp = const Sock; _Deleter = Sock::Wait(std::chrono::milliseconds, Event, Event*) const::<lambda(const Sock*)>; <template-parameter-2-3> = void; _Tp = const Sock] at /opt/gcc-latest/include/c++/16.0.1/bits/shared_ptr.h:231:48,
    87    inlined from virtual bool Sock::Wait(std::chrono::milliseconds, Event, Event*) const at /b-c/src/util/sock.cpp:144:64:
    88/opt/gcc-latest/include/c++/16.0.1/bits/new_allocator.h:151:73: note: object of size 24 allocated by operator new
    89  151 |         return static_cast<_Tp*>(_GLIBCXX_OPERATOR_NEW(__n * sizeof(_Tp)));
    90      |                                                                         ^
    91[ 13%] Linking CXX static library ../../lib/libbitcoin_util.a
    

    (This pull fixes it)

  5. refactor: Use aliasing shared_ptr in Sock::Wait faa016af54
  6. maflcko force-pushed on Feb 3, 2026
  7. hodlinator approved
  8. hodlinator commented at 1:17 pm on February 10, 2026: contributor

    ACK faa016af542763492a63de8cc972f8f4b52a58cd

    Uses shared_ptr’s aliasing ctor1 to have the local shared variable to take over the any heap-allocated refcount, which can even be nullptr for default-initialized shared_ptrs. (Example usage of l-value overload of aliasing ctor: https://stackoverflow.com/a/27109774).

    (The custom deleter on master would need to live on the heap to outlive short-lived shared_ptr instances. The refcount and custom deleter would probably be allocated together, but specializations of shared_ptr without the custom deleter could have a smaller allocation).

    Edit: Slight correction after #34471 (comment)

  9. maflcko commented at 1:46 pm on February 10, 2026: member

    Uses shared_ptr’s aliasing ctor to have the local shared variable to take over the heap-allocated refcount (https://en.cppreference.com/w/cpp/memory/shared_ptr/shared_ptr.html) . (Example usage of l-value overload of aliasing ctor: https://stackoverflow.com/a/27109774).

    Just for reference, and not important, but in the specific case of the code in this pull request, there is no need for any heap-allocation at all. It is just two nullptr on the stack (for the empty ptr), and still two pointers on the stack after passing to the aliasing ctor. At least in libcxx: https://github.com/llvm/llvm-project/blob/2f0400c1a15b7b1ff401cc12902f7de5856cf1f7/libcxx/include/__memory/shared_ptr.h#L321-L328 and https://github.com/llvm/llvm-project/blob/2f0400c1a15b7b1ff401cc12902f7de5856cf1f7/libcxx/include/__memory/shared_ptr.h#L426-L443

  10. maflcko commented at 1:55 pm on February 10, 2026: member
    cc @vasild (author of the original code, may be qualified to ack/nack this)

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-02-11 21:13 UTC

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