Document sizeof(size_t) assumptions and compiler assumptions by adding compile-time checks in assumptions.h.
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-
practicalswift commented at 1:21 PM on March 4, 2019: contributor
-
Add sizeof(size_t) assumptions c7ea8d3236
- fanquake added the label Refactoring on Mar 4, 2019
-
scravy commented at 1:28 PM on March 4, 2019: contributor
utACK c7ea8d3236e7c1b0c198345cc78a6754338d3724
-
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 useuintptr_tif you want an integer type the same size as a pointer, but ok we do make it in practice) - 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 -
practicalswift commented at 7:25 PM on March 4, 2019: contributor
- 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 -
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.
-
practicalswift commented at 8:31 PM on March 4, 2019: contributor
@scravy When adding
assumptions.hthe 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:-) - Could it help sound static analysis or other types of formal analysis if an assumption we make was specified explicitly in
-
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).
-
practicalswift commented at 10:16 AM on March 5, 2019: contributor
@laanwj I've now changed to
__cplusplus >= 201103Lto 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 :-) - practicalswift force-pushed on Mar 5, 2019
-
Document assumptions about C++ compiler c7a7250302
- practicalswift force-pushed on Mar 5, 2019
-
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 ... #endifWDYT? :-)
-
practicalswift commented at 8:37 AM on March 14, 2019: contributor
@laanwj Ping - what is your preference? :-)
-
practicalswift commented at 4:55 PM on March 15, 2019: contributor
FWIW: I've verified that a disassembly of the
bitcoindbinary built with this patch applied is identical to a disassembly of thebitcoindbinary built againstmaster(as expected). - laanwj merged this on Mar 16, 2019
- laanwj closed this on Mar 16, 2019
- laanwj referenced this in commit 2f501fb5c6 on Mar 16, 2019
-
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
- jasonbcox referenced this in commit 418fdfff85 on Oct 8, 2020
- practicalswift deleted the branch on Apr 10, 2021
- PastaPastaPasta referenced this in commit f8d2cb666d on Jun 27, 2021
- PastaPastaPasta referenced this in commit a52d22df99 on Jun 28, 2021
- PastaPastaPasta referenced this in commit 9ea188c117 on Jun 29, 2021
- PastaPastaPasta referenced this in commit 34f03b2cda on Jul 1, 2021
- PastaPastaPasta referenced this in commit 3f8e0631f2 on Jul 1, 2021
- PastaPastaPasta referenced this in commit 93a7dc3fed on Jul 8, 2021
- PastaPastaPasta referenced this in commit 9c3401a91d on Jul 10, 2021
- DrahtBot locked this on Aug 16, 2022