Skip to content

Commit

Permalink
Merge bitcoin#12896: docs: Fix conflicting statements about initializ…
Browse files Browse the repository at this point in the history
…ation 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#12785 (comment)

Tree-SHA512: 601b18cbeb963f99a4180e652d6c1b78210df89743fd3565c0bce95fd2dcc9784b6af212795a43d3a40a5858b1a03e0d2c7982295c92d6ea710db0e6ee69f0b4
  • Loading branch information
laanwj authored and PastaPastaPasta committed Jul 17, 2020
1 parent bf17266 commit 9c357d0
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions doc/developer-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,21 @@ C++ data structures

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

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

- *Rationale*: Ensure determinism by avoiding accidental use of uninitialized
values. Also, static analyzers balk about this.
Initializing the members in the declaration makes it easy to
spot uninitialized ones.

```cpp
class A
{
uint32_t m_count{0};
}
```
- By default, declare single-argument constructors `explicit`.
Expand All @@ -399,18 +408,6 @@ C++ data structures
- *Rationale*: Easier to understand what is happening, thus easier to spot mistakes, even for those
that are not language lawyers
- Initialize all non-static class members where they are defined

- *Rationale*: Initializing the members in the declaration makes it easy to spot uninitialized ones,
and avoids accidentally reading uninitialized memory

```cpp
class A
{
uint32_t m_count{0};
}
```
Strings and formatting
------------------------
Expand Down

0 comments on commit 9c357d0

Please sign in to comment.