build: warn on potentially uninitialized reads#18843
Conversation
|
Code review ACK |
|
Concept ACK |
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
|
Please don't bundle unrelated changes like fe466a4 into a PR like this.
Can you at least link to documentation that says this is the case. |
d1fa090 to
23faed0
Compare
Sorry for that. I considered it would be ok as long as it is a separate commit and the main change in this PR steps on top of it. Now I submitted that dedup as a separate PR at #18857, removed it from this PR and made this PR to use the old
Done in the commit message:
Thanks for looking into this! |
Enable -Wconditional-uninitialized to warn on potentially uninitialized reads. Fix the sole such warning in Bitcoin Core in GetRdRand(): r1 would be set to 0 on rdrand failure, so initializing it to 0 is a non-functional change. From "Intel 64 and IA-32 ArchitecturesSoftware Developer's Manual" [1], page 1711: "CF=1 indicates that the data in the destination is valid. Otherwise CF=0 and the data in the destination operand will be returned as zeros for the specified width." [1] https://software.intel.com/sites/default/files/managed/39/c5/325462-sdm-vol-1-2abcd-3abcd.pdf
23faed0 to
71f183a
Compare
|
It would be more readable to use Out of the scope of this PR. |
|
@vasild The annoying part about using intrinsics is that they require moving the code to a separate module and compiling it separately. That's because in order to get access to |
|
ACK 71f183a |
|
ACK 71f183a |
71f183a build: warn on potentially uninitialized reads (Vasil Dimov) Pull request description: * Enable `conditional-uninitialized` warning class to show potentially uninitialized reads. * Fix the sole such warning in Bitcoin Core in `GetRdRand()`: `r1` would be set to `0` on `rdrand` failure, so initializing it to `0` is a non-functional change. ACKs for top commit: practicalswift: ACK 71f183a laanwj: ACK 71f183a Tree-SHA512: 2c1d8caacd86424b16a9d92e5df19e0bedb51ae111eecad7e3bfa46447bc88e5fff1f32dacf6c4a28257ebb3d87e79f80f074ce2c523ce08b1a0c0a67ab44204
Summary: > Enable -Wconditional-uninitialized to warn on potentially uninitialized reads. > > Fix the sole such warning in Bitcoin Core in GetRdRand(): r1 would be > set to 0 on rdrand failure, so initializing it to 0 is a non-functional > change. > > From "Intel 64 and IA-32 ArchitecturesSoftware Developer's Manual" [1], > page 1711: "CF=1 indicates that the data in the destination is valid. > Otherwise CF=0 and the data in the destination operand will be returned > as zeros for the specified width." > > [1] https://software.intel.com/sites/default/files/managed/39/c5/325462-sdm-vol-1-2abcd-3abcd.pdf This is a backport of Core [[bitcoin/bitcoin#18843 | PR18843]] Test Plan: ``` cmake .. -GNinja \ -DCMAKE_C_COMPILER=clang \ -DCMAKE_CXX_COMPILER=clang++ \ -DENABLE_CLANG_TIDY=ON \ -DCMAKE_C_FLAGS="-Werror" ninja all check-all ``` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D9110
merge bitcoin#18914, bitcoin#13306, bitcoin#16424, bitcoin#13899, bitcoin#17486, bitcoin#17880, bitcoin#18145, bitcoin#18843, bitcoin#16710: split warnings out of CXXFLAGS, add more flags
Enable
conditional-uninitializedwarning class to show potentially uninitializedreads.
Fix the sole such warning in Bitcoin Core in
GetRdRand():r1would beset to
0onrdrandfailure, so initializing it to0is a non-functionalchange.