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
  1. shargon commented at 3:24 PM on August 23, 2019: none

    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.

  2. static_assert to ensure width in unit class a1d85e7cc2
  3. static_assert to ensure width in unit class
    
    Add one more
    2c5a6cc634
  4. Merge remote-tracking branch 'origin/fix-uintbase' into fix-uintbase 30978241dd
  5. 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.

  6. More asserts ca5ee1ef9f
  7. shargon commented at 3:40 PM on August 23, 2019: none

    @tryphe Thanks, was forgotten

  8. More asserts 6509273e9d
  9. 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.

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

  11. laanwj added the label Waiting for author on Oct 2, 2019
  12. laanwj added the label Validation on Oct 2, 2019
  13. 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
    
  14. 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
  15. practicalswift commented at 2:54 PM on October 28, 2019: contributor

    Concept ACK: compile time checking cannot hurt

  16. fanquake deleted a comment on Oct 28, 2019
  17. MarcoFalke commented at 3:19 PM on October 28, 2019: member

    @shargon Are you still working on this?

  18. shargon commented at 2:12 AM on October 29, 2019: none

    I am on vacations, please give me a week.

  19. shargon commented at 12:26 PM on November 13, 2019: none

    Could you summarize the expected changes and confirm that it could be merged in order to avoid the waste of time as #16310

  20. MarcoFalke commented at 1:36 PM on November 13, 2019: member

    Adding static_asserts to document assumptions is nice, but they must have no false positives.

  21. fanquake commented at 8:12 AM on January 25, 2020: member

    Let me know if you want this reopened.

  22. fanquake closed this on Jan 25, 2020

  23. fanquake removed the label Waiting for author on May 28, 2020
  24. shargon deleted the branch on Oct 26, 2021
  25. DrahtBot locked this on Oct 30, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-22 09:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me