Skip to content

Commit b15485e

Browse files
committed
Merge #12896: docs: Fix conflicting statements about initialization in developer notes
b119e78 docs: Fix conflicting statements about initialization in developer notes (practicalswift) Pull request description: Fix conflicting statements about initialization in developer notes. Context: bitcoin/bitcoin#12785 (comment) Tree-SHA512: 601b18cbeb963f99a4180e652d6c1b78210df89743fd3565c0bce95fd2dcc9784b6af212795a43d3a40a5858b1a03e0d2c7982295c92d6ea710db0e6ee69f0b4
2 parents 215158a + b119e78 commit b15485e

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

doc/developer-notes.md

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -450,12 +450,21 @@ C++ data structures
450450

451451
- Vector bounds checking is only enabled in debug mode. Do not rely on it
452452

453-
- Make sure that constructors initialize all fields. If this is skipped for a
454-
good reason (i.e., optimization on the critical path), add an explicit
455-
comment about this
453+
- Initialize all non-static class members where they are defined.
454+
If this is skipped for a good reason (i.e., optimization on the critical
455+
path), add an explicit comment about this
456456

457457
- *Rationale*: Ensure determinism by avoiding accidental use of uninitialized
458458
values. Also, static analyzers balk about this.
459+
Initializing the members in the declaration makes it easy to
460+
spot uninitialized ones.
461+
462+
```cpp
463+
class A
464+
{
465+
uint32_t m_count{0};
466+
}
467+
```
459468
460469
- By default, declare single-argument constructors `explicit`.
461470
@@ -474,18 +483,6 @@ C++ data structures
474483
- *Rationale*: Easier to understand what is happening, thus easier to spot mistakes, even for those
475484
that are not language lawyers
476485
477-
- Initialize all non-static class members where they are defined
478-
479-
- *Rationale*: Initializing the members in the declaration makes it easy to spot uninitialized ones,
480-
and avoids accidentally reading uninitialized memory
481-
482-
```cpp
483-
class A
484-
{
485-
uint32_t m_count{0};
486-
}
487-
```
488-
489486
Strings and formatting
490487
------------------------
491488

0 commit comments

Comments
 (0)