Page MenuHomePhabricator

Merge #12537: [arith_uint256] Make it safe to use "self" in operators
ClosedPublic

Authored by jasonbcox on Wed, Aug 7, 20:41.

Details

Summary

b120f7b [test] Add tests for self usage in arith_uint256 (Karl-Johan Alm)
08b17de [arith_uint256] Do not destroy *this content if passed-in operator may reference it (Karl-Johan Alm)

Pull request description:

Before this fix (see test commit), `v *= v` would result in `0` because `operator*=` set `*this` (`==b`) to `0` at the start. This patch changes the code to use `a` as temporary for `*this`~~, with drawback that `*this` is set to `a` at the end, an extra `=` operation in other words~~.

Tree-SHA512: 8028a99880c3198a39c4bcc5056169735ba960625d553e15c0317510a52940c875f7a1fefe14e1af7fcf10c07a246411994a328cb1507bf3eaf1b6e7425390dc

Backport of Core PR12537

https://github.com/bitcoin/bitcoin/pull/12537/files

Test Plan

make check

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

jasonbcox created this revision.Wed, Aug 7, 20:41
jasonbcox planned changes to this revision.Wed, Aug 7, 20:41
jasonbcox requested review of this revision.Wed, Aug 7, 20:42
Fabien accepted this revision.Thu, Aug 8, 08:23
This revision is now accepted and ready to land.Thu, Aug 8, 08:23