The typo is harmless, but a bit confusing every time i read it
doc: Fix wrong code in WITH_LOCK doxygen comment #34355
pull maflcko wants to merge 1 commits into bitcoin:master from maflcko:2601-doc-fix-code changing 1 files +2 −2-
maflcko commented at 4:52 PM on January 20, 2026: member
- DrahtBot added the label Docs on Jan 20, 2026
-
DrahtBot commented at 4:52 PM on January 20, 2026: contributor
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--006a51241073e994b41acfe9ec718e94-->
Code Coverage & Benchmarks
For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/34355.
<!--021abf342d371248e50ceaed478a90ca-->
Reviews
See the guideline for information on the review process.
If your review is incorrectly listed, please copy-paste <code><!--meta-tag:bot-skip--></code> into the comment that the bot should ignore.
<!--5faf32d7da4f0f540f40219e4f7537a3-->
-
in src/sync.h:284 in fa07e52616
281 | +//! WITH_LOCK(cs, int i = 1; return i;); 282 | //! 283 | //! is int, the deduced type of: 284 | //! 285 | -//! WITH_LOCK(cs, return {int j = 1; return (j);}); 286 | +//! WITH_LOCK(cs, int j = 1; return (j););
l0rinc commented at 5:10 PM on January 20, 2026:what's the purpose of
(j)?
maflcko commented at 5:47 PM on January 20, 2026:It is used to explain
&int, which is different than theintabove.
l0rinc commented at 10:20 AM on January 22, 2026:Do you mean that
//! WITH_LOCK(cs, int j = 1; return j);wouldn't work, only
//! WITH_LOCK(cs, int j = 1; return (j));? Why do we need to group it, not sure I understand?
maflcko commented at 10:53 AM on January 22, 2026:jis different than(j). One is int, the other is&intafter decltype(auto) return type deduction#include <type_traits> #define WITH_CODE(code) [&]() -> decltype(auto) { code; }() int main() { // Case 1: returns int (by value) static_assert( std::is_same_v<decltype(WITH_CODE(int i = 1; return i;)), int>); // Case 2: returns int& (reference to local variable) static_assert( std::is_same_v<decltype(WITH_CODE(int j = 1; return (j);)), int&>); // Compile-time check for reference-to-local static_assert(std::is_lvalue_reference_v<decltype(WITH_CODE(int k = 1; return (k);))>); }
maflcko commented at 11:41 AM on January 22, 2026:Also, with C++23, it will be
int&&: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2266r3.html#decltype-autoin src/sync.h:280 in fa07e52616
276 | @@ -277,11 +277,11 @@ inline MutexType* MaybeCheckNotHeld(MutexType* m) LOCKS_EXCLUDED(m) LOCK_RETURNE 277 | //! Since the return type deduction follows that of decltype(auto), while the 278 | //! deduced type of: 279 | //! 280 | -//! WITH_LOCK(cs, return {int i = 1; return i;}); 281 | +//! WITH_LOCK(cs, int i = 1; return i;);
l0rinc commented at 5:10 PM on January 20, 2026:We usually don't have a
;inside, e.g.: https://github.com/bitcoin/bitcoin/blob/7f5ebef56a0f2bad7df30252b11da3e33cb3c144/src/net.h#L429
maflcko commented at 5:46 PM on January 20, 2026:Correct. However, the docs here exist to explain
decltype(auto).
maflcko commented at 1:52 PM on January 21, 2026:i guess i didn't understand the comment here. the first semicolon is required, but the second can be removed, so i did that
l0rinc changes_requestedhebasto approvedhebasto commented at 1:35 PM on January 21, 2026: memberACK fa07e5261666c808613d9ce9c201cc7a0ca6b80e, the current code snippets have wrong syntax.
I agree with #34355 (review), as the semicolon is now trailing and should be dropped. Happy to re-ACK once this is addressed.
doc: Fix wrong code in WITH_LOCK doxygen comment fa61fadad1maflcko force-pushed on Jan 21, 2026hebasto approvedhebasto commented at 2:05 PM on January 21, 2026: memberre-ACK fa61fadad1c3df0274c3ddd351b8d68a0c4fe644.
l0rinc commented at 10:21 AM on January 22, 2026: contributorACK fa61fadad1c3df0274c3ddd351b8d68a0c4fe644
hebasto merged this on Jan 22, 2026hebasto closed this on Jan 22, 2026maflcko deleted the branch on Jan 22, 2026
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-04-22 18:12 UTC
More mirrored repositories can be found on mirror.b10c.me