On msvc14, int literal '-2147483648' is invalid, because '2147483648' is unsigned type and cant't apply minus operator to unsigned type. To define the int literal correctly, use '-2147483647 - 1' formula that is also used to define INT_MIN in limits.h.
Fix msvc compiler error C4146 (unary minus operator applied to unsigned type #16458
pull Chunbao wants to merge 1 commits into bitcoin:0.17 from Chunbao:fix-C4146-in-util-test changing 1 files +1 −1-
Chunbao commented at 2:46 PM on July 25, 2019: none
-
3c73d820e2
Fix msvc compiler error C4146 (unary minus operator applied to unsigned type)
On msvc14, int literal '-2147483648' is invalid, because '2147483648' is unsigned type and cant't apply minus operator to unsigned type. To define the int literal correctly, use '-2147483647 - 1' formula that is also used to define INT_MIN in limits.h.
- fanquake added the label Tests on Jul 25, 2019
- laanwj renamed this:
Fix msvc compiler error C4146 (unary minus operator applied to unsign…
Fix msvc compiler error C4146 (unary minus operator applied to unsigned type
on Jul 25, 2019 - laanwj approved
-
laanwj commented at 3:19 PM on July 25, 2019: member
ACK 3c73d820e2355b36ea6bd6c4b78e4afa82637b8f
-
fanquake commented at 11:53 PM on July 28, 2019: member
cc @sipsorcery
- fanquake added the label Windows on Jul 28, 2019
-
sipsorcery commented at 8:01 AM on July 29, 2019: member
@fanquake I can't workout what's going on with this PR.
To me it looks like an existing commit 8e0720bdb9141b00b4c00893b8139904c67ddacf from a fork of a fork that's already been applied.
The change is already on the
0.17branch. I can't workout why the github UI is displaying the file diff as a single line change. If I checkout0.17and apply this PR manually thesrc/test/util_tests.cppfile does not get changed. Maybe I'm missing something? -
fanquake commented at 8:24 AM on July 29, 2019: member
@sipsorcery Looks like your correct. The change is definitely already in the
0.17branch. https://github.com/bitcoin/bitcoin/blob/c165df198d6e9ea7292af0578024113803b8a6a2/src/test/util_tests.cpp#L833I'm not sure why GitHub is presenting this diff.
- fanquake closed this on Jul 29, 2019
- MarcoFalke reopened this on Jul 29, 2019
- MarcoFalke closed this on Jul 29, 2019
-
laanwj commented at 1:49 PM on July 29, 2019: member
Hadn't noticed that this targeted a branch instead of master.
-
MarcoFalke commented at 2:05 PM on July 29, 2019: member
8e0720b is in all supported branches
- MarcoFalke locked this on Dec 16, 2021