Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[developer-notes] By default, declare single-argument constructors "explicit" #11112

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/developer-notes.md
Expand Up @@ -332,6 +332,12 @@ C++ data structures
- *Rationale*: Ensure determinism by avoiding accidental use of uninitialized
values. Also, static analyzers balk about this.

- By default, declare single-argument constructors `explicit`.

- *Rationale*: This is a precaution to avoid unintended conversions that might
arise when single-argument constructors are used as implicit conversion
functions.

- Use explicitly signed or unsigned `char`s, or even better `uint8_t` and
`int8_t`. Do not use bare `char` unless it is to pass to a third-party API.
This type can be signed or unsigned depending on the architecture, which can
Expand Down
2 changes: 1 addition & 1 deletion src/test/addrman_tests.cpp
Expand Up @@ -15,7 +15,7 @@ class CAddrManTest : public CAddrMan
uint64_t state;

public:
CAddrManTest(bool makeDeterministic = true)
explicit CAddrManTest(bool makeDeterministic = true)
{
state = 1;

Expand Down