Skip to content

Mark single-argument constructors "explicit"#13769

Merged
maflcko merged 1 commit intobitcoin:masterfrom
practicalswift:explicit
Aug 27, 2018
Merged

Mark single-argument constructors "explicit"#13769
maflcko merged 1 commit intobitcoin:masterfrom
practicalswift:explicit

Conversation

@practicalswift
Copy link
Contributor

@practicalswift practicalswift commented Jul 26, 2018

Mark single-argument constructors explicit.

Rationale:

  • Avoid unexpected implicit promotions.

From the developer notes:

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.

@maflcko
Copy link
Member

maflcko commented Jul 26, 2018

Would be nice if explicit was the default for constructors unless you specify otherwise, but I guess we are stuck with cpp currently works.

Is there was a flag for a compile time warning or similar at least?

@kallewoof
Copy link
Contributor

Concept ACK (unexpected implicit promotions are bad and 9 lines is OK), assuming there is a compile flag or non-false-positive-inducing linter that can plug this.

@practicalswift
Copy link
Contributor Author

Forgot to include this excerpt from the developer notes:

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.

@maflcko
Copy link
Member

maflcko commented Jul 31, 2018

utACK 1ac3c98

@promag
Copy link
Contributor

promag commented Jul 31, 2018

utACK 1ac3c98. Are there more candidates?

@practicalswift
Copy link
Contributor Author

@promag Thanks for reviewing! These should be all AFAIK :-)

@Empact
Copy link
Contributor

Empact commented Aug 2, 2018

utACK 1ac3c98

@practicalswift
Copy link
Contributor Author

Ready for merge? :-)

maflcko pushed a commit to maflcko/bitcoin-core that referenced this pull request Aug 27, 2018
1ac3c98 Mark single-argument constructors "explicit" (practicalswift)

Pull request description:

  Mark single-argument constructors `explicit`.

  Rationale:
  * Avoid unexpected implicit promotions.

  From the developer notes:

  > **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.

Tree-SHA512: 7901ed5be808c9d0ecb5ca501e1bc0395987fe1b7941b8548cebac2ff08a14f7dab61fab374a69b9ba29a9295a04245c814325c7f95b97ae558af0780f111dfa
@maflcko maflcko merged commit 1ac3c98 into bitcoin:master Aug 27, 2018
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request May 16, 2020
Summary:
bitcoin/bitcoin@1ac3c98

---

This is a backport of Core [[bitcoin/bitcoin#13769 | PR13769]]

Test Plan:
  ninja check-all

Reviewers: #bitcoin_abc, nakihito

Reviewed By: nakihito

Differential Revision: https://reviews.bitcoinabc.org/D6072
ftrader pushed a commit to bitcoin-cash-node/bitcoin-cash-node that referenced this pull request Aug 17, 2020
Summary:
bitcoin/bitcoin@1ac3c98

---

This is a backport of Core [[bitcoin/bitcoin#13769 | PR13769]]

Test Plan:
  ninja check-all

Reviewers: #bitcoin_abc, nakihito

Reviewed By: nakihito

Differential Revision: https://reviews.bitcoinabc.org/D6072
@practicalswift practicalswift deleted the explicit branch April 10, 2021 19:35
pravblockc pushed a commit to pravblockc/dash that referenced this pull request Jul 26, 2021
1ac3c98 Mark single-argument constructors "explicit" (practicalswift)

Pull request description:

  Mark single-argument constructors `explicit`.

  Rationale:
  * Avoid unexpected implicit promotions.

  From the developer notes:

  > **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.

Tree-SHA512: 7901ed5be808c9d0ecb5ca501e1bc0395987fe1b7941b8548cebac2ff08a14f7dab61fab374a69b9ba29a9295a04245c814325c7f95b97ae558af0780f111dfa
pravblockc pushed a commit to pravblockc/dash that referenced this pull request Aug 3, 2021
1ac3c98 Mark single-argument constructors "explicit" (practicalswift)

Pull request description:

  Mark single-argument constructors `explicit`.

  Rationale:
  * Avoid unexpected implicit promotions.

  From the developer notes:

  > **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.

Tree-SHA512: 7901ed5be808c9d0ecb5ca501e1bc0395987fe1b7941b8548cebac2ff08a14f7dab61fab374a69b9ba29a9295a04245c814325c7f95b97ae558af0780f111dfa
gades pushed a commit to cosanta/cosanta-core that referenced this pull request May 9, 2022
1ac3c98 Mark single-argument constructors "explicit" (practicalswift)

Pull request description:

  Mark single-argument constructors `explicit`.

  Rationale:
  * Avoid unexpected implicit promotions.

  From the developer notes:

  > **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.

Tree-SHA512: 7901ed5be808c9d0ecb5ca501e1bc0395987fe1b7941b8548cebac2ff08a14f7dab61fab374a69b9ba29a9295a04245c814325c7f95b97ae558af0780f111dfa
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants