Document sizeof(size_t) assumptions and compiler assumptions in assumptions.h #15522

pull practicalswift wants to merge 2 commits into bitcoin:master from practicalswift:size_t-assumptions changing 1 files +17 −1
  1. practicalswift commented at 1:21 PM on March 4, 2019: contributor

    Document sizeof(size_t) assumptions and compiler assumptions by adding compile-time checks in assumptions.h.

  2. Add sizeof(size_t) assumptions c7ea8d3236
  3. fanquake added the label Refactoring on Mar 4, 2019
  4. scravy commented at 1:28 PM on March 4, 2019: contributor

    utACK c7ea8d3236e7c1b0c198345cc78a6754338d3724

  5. laanwj commented at 3:37 PM on March 4, 2019: member

    utACK c7ea8d3236e7c1b0c198345cc78a6754338d3724 (I don't think these are necessary assumptions, you're supposed to use uintptr_t if you want an integer type the same size as a pointer, but ok we do make it in practice)

  6. practicalswift renamed this:
    Document sizeof(size_t) assumptions in assumptions.h
    Document sizeof(size_t) and compiler assumptions in assumptions.h
    on Mar 4, 2019
  7. practicalswift commented at 7:25 PM on March 4, 2019: contributor

    @scravy @laanwj Added compiler assumptions for completeness. Please re-review :-)

  8. practicalswift renamed this:
    Document sizeof(size_t) and compiler assumptions in assumptions.h
    Document sizeof(size_t) assumptions and compiler assumptions in assumptions.h
    on Mar 4, 2019
  9. scravy commented at 7:40 PM on March 4, 2019: contributor

    I am not sure that the C++11 assumption is needed. The assumptions in here are about the platform, i.e. hardware, system configuration, etc.

    Whether bitcoin is built using C++11 or not is pretty much up to the build system, not so much to the underlying platform (whereas I might just be able to configure/make on some alien system violating assumptions about certain types).

    I'm not fundamentally opposed it, but I also do not see any necessity for it.

  10. practicalswift commented at 8:31 PM on March 4, 2019: contributor

    @scravy When adding assumptions.h the goal was to document all tacit assumptions we make that don't follow directly from the standard used. Not specifying the standard was just an oversight from my part -- it should have been there from the beginning :-)

    A thought experiment that can be made when considering if an assumption should be specified explicitly:

    • Could it help sound static analysis or other types of formal analysis if an assumption we make was specified explicitly in assumptions.h?

    If the answer is yes the assumption should probably be explicitly stated in assumptions.h :-)

  11. laanwj commented at 9:56 AM on March 5, 2019: member

    I am not sure that the C++11 assumption is needed. The assumptions in here are about the platform, i.e. hardware, system configuration, etc.

    I tend to agree. I like documenting specific, concrete assumptions here about platforms and environments. Asserting the C++11 macros seems too sweeping and general. Is there any specific reason bitcoind cannot be built with C++14 or 19 mode if so desired? Will this result in expected bugs besides "we haven't tested it"? If not, let's not include it (have retracted my ACK for now).

  12. practicalswift commented at 10:16 AM on March 5, 2019: contributor

    @laanwj I've now changed to __cplusplus >= 201103L to make sure the compiler supports "at least" the final version of C++11. This will allow for building also in say C++14 or 17 mode. Please re-review :-)

  13. practicalswift force-pushed on Mar 5, 2019
  14. Document assumptions about C++ compiler c7a7250302
  15. practicalswift force-pushed on Mar 5, 2019
  16. practicalswift commented at 11:05 PM on March 5, 2019: contributor

    @laanwj An alternative would be to simply issue a warning if a non-C++11 (ISO/IEC 14882:2011) compiler is used:

    #if __cplusplus != 201104L
    #warning ...
    #endif
    

    WDYT? :-)

  17. practicalswift commented at 8:37 AM on March 14, 2019: contributor

    @laanwj Ping - what is your preference? :-)

  18. practicalswift commented at 4:55 PM on March 15, 2019: contributor

    FWIW: I've verified that a disassembly of the bitcoind binary built with this patch applied is identical to a disassembly of the bitcoind binary built against master (as expected).

  19. laanwj merged this on Mar 16, 2019
  20. laanwj closed this on Mar 16, 2019

  21. laanwj referenced this in commit 2f501fb5c6 on Mar 16, 2019
  22. laanwj commented at 4:13 PM on March 16, 2019: member

    This is fine, let's not have an endless discussion over a pretty insignificant change like this.

    FWIW: I've verified that a disassembly of the bitcoind binary built with this patch applied is identical to a disassembly of the bitcoind binary built against master (as expected).

    THanks for testing, utACK

  23. jasonbcox referenced this in commit 418fdfff85 on Oct 8, 2020
  24. practicalswift deleted the branch on Apr 10, 2021
  25. PastaPastaPasta referenced this in commit f8d2cb666d on Jun 27, 2021
  26. PastaPastaPasta referenced this in commit a52d22df99 on Jun 28, 2021
  27. PastaPastaPasta referenced this in commit 9ea188c117 on Jun 29, 2021
  28. PastaPastaPasta referenced this in commit 34f03b2cda on Jul 1, 2021
  29. PastaPastaPasta referenced this in commit 3f8e0631f2 on Jul 1, 2021
  30. PastaPastaPasta referenced this in commit 93a7dc3fed on Jul 8, 2021
  31. PastaPastaPasta referenced this in commit 9c3401a91d on Jul 10, 2021
  32. DrahtBot locked this on Aug 16, 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-16 15:14 UTC

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