Page MenuHomePhabricator

Declare single-argument (non-converting) constructors "explicit"
ClosedPublic

Authored by Fabien on Dec 19 2018, 10:45.

Details

Summary

In order to avoid unintended implicit conversions.

Backport of core PR10969
Depends on D2205, D2206 and D2212

Test Plan
make check

Diff Detail

Repository
rABC Bitcoin ABC
Branch
PR10969
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 4328
Build 6721: Bitcoin ABC Buildbot (legacy)
Build 6720: arc lint + arc unit

Event Timeline

jasonbcox requested changes to this revision.Dec 20 2018, 00:38
jasonbcox added a subscriber: jasonbcox.

reverse_iterator.h and qt/callback.h have changes in the backport, but these files do not exist in ABC. Are there backports we need that this depends on?

Also missing explicit on ConnectTrace constructor in validation.cpp

src/blockencodings.h
226

Missed one

src/chain.h
250

Remove this. Looks accidentally added.

src/netaddress.h
39

Missed

103

Missed

src/qt/utilitydialog.h
42

nullptr change isn't part of the backport, but looks fine to me

src/support/lockedpool.h
238

Missed

src/tinyformat.h
166

Is there a missing backport for format_error?

src/wallet/wallet.h
720

This should be explicit. The backport has a similar, but not identical, constructor

This revision now requires changes to proceed.Dec 20 2018, 00:38

tinyformat format_error:
The missing backport is PR9963, which addresses the consequences of a format error. IMO this is not a good idea because it does not solve the root issue, the bad format itself (if you remember, some have been fixed recently in addrman). A later PR propose a linter to avoid the format issues which seems by far a better option to me.

qt/callback.h
The missing backport is PR10098, which fixes QT4 compatibility issues. This is reversed in PR14527 when support for QT4 is dropped, so there is no reason backport PR10098.

reverse_iterator.h
The missing backport is PR10193, which is intended to remove BOOST_FOREACH. The method actually used in the codebase is boost::adaptors::reverse. I don't really see any advantage in using a custom reverse_iterator implementation here, as boost is already used everywhere in the code.

src/blockencodings.h
226

This backport is only about single argument constructors

src/qt/utilitydialog.h
42

Yes it's part of D2206, which is supposed to be a dependency... I may have missed a rebase

This revision is now accepted and ready to land.Dec 21 2018, 21:35