Because operators are implemented in the base class, and being inherited by uint256 and unit512, if a copy or read is made between these types, random memory would be being accessed.
validation: static_assert to ensure width in unit class #16696
pull shargon wants to merge 5 commits into bitcoin:master from shargon:fix-uintbase changing 1 files +16 −0-
shargon commented at 3:24 PM on August 23, 2019: none
-
static_assert to ensure width in unit class a1d85e7cc2
-
2c5a6cc634
static_assert to ensure width in unit class
Add one more
-
Merge remote-tracking branch 'origin/fix-uintbase' into fix-uintbase 30978241dd
-
tryphe commented at 3:36 PM on August 23, 2019: contributor
Why skip the other functions, like
operator =? It seems like the same rationale should apply. Just curious. -
More asserts ca5ee1ef9f
-
More asserts 6509273e9d
-
DrahtBot commented at 5:38 AM on August 24, 2019: member
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--174a7506f384e20aa4161008e828411d-->
Conflicts
No conflicts as of last run.
-
laanwj commented at 11:32 AM on September 16, 2019: member
ACK, looks good to me, these sanity asserts can't hurt.Please squash your commits.
- laanwj added the label Waiting for author on Oct 2, 2019
- laanwj added the label Validation on Oct 2, 2019
-
laanwj commented at 10:34 AM on October 28, 2019: member
This gives me the following compile error (clang linux)
/…/bitcoin/src/arith_uint256.h:51:32: error: static_assert expression is not an integral constant expression static_assert(WIDTH == b.WIDTH, "Template parameter WIDTH must be equal."); ~~~~~~~~~^~~~~~~ /…/bitcoin/src/arith_uint256.h:268:7: note: in instantiation of member function 'base_uint<256>::operator=' requested here class arith_uint256 : public base_uint<256> { ^ 1 error generated - fanquake renamed this:
[validation] static_assert to ensure width in unit class
validation: static_assert to ensure width in unit class
on Oct 28, 2019 -
practicalswift commented at 2:54 PM on October 28, 2019: contributor
Concept ACK: compile time checking cannot hurt
- fanquake deleted a comment on Oct 28, 2019
-
MarcoFalke commented at 3:19 PM on October 28, 2019: member
@shargon Are you still working on this?
-
shargon commented at 2:12 AM on October 29, 2019: none
I am on vacations, please give me a week.
-
MarcoFalke commented at 1:36 PM on November 13, 2019: member
Adding
static_assertsto document assumptions is nice, but they must have no false positives. -
fanquake commented at 8:12 AM on January 25, 2020: member
Let me know if you want this reopened.
- fanquake closed this on Jan 25, 2020
- fanquake removed the label Waiting for author on May 28, 2020
- shargon deleted the branch on Oct 26, 2021
- DrahtBot locked this on Oct 30, 2022
Labels