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
  1. Chunbao commented at 2:46 PM on July 25, 2019: none

    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.

  2. 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.
    3c73d820e2
  3. fanquake added the label Tests on Jul 25, 2019
  4. 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
  5. laanwj approved
  6. laanwj commented at 3:19 PM on July 25, 2019: member

    ACK 3c73d820e2355b36ea6bd6c4b78e4afa82637b8f

  7. fanquake commented at 11:53 PM on July 28, 2019: member
  8. fanquake added the label Windows on Jul 28, 2019
  9. 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.17 branch. I can't workout why the github UI is displaying the file diff as a single line change. If I checkout 0.17 and apply this PR manually the src/test/util_tests.cpp file does not get changed. Maybe I'm missing something?

  10. fanquake commented at 8:24 AM on July 29, 2019: member

    @sipsorcery Looks like your correct. The change is definitely already in the 0.17 branch. https://github.com/bitcoin/bitcoin/blob/c165df198d6e9ea7292af0578024113803b8a6a2/src/test/util_tests.cpp#L833

    I'm not sure why GitHub is presenting this diff.

  11. fanquake closed this on Jul 29, 2019

  12. MarcoFalke reopened this on Jul 29, 2019

  13. MarcoFalke closed this on Jul 29, 2019

  14. laanwj commented at 1:49 PM on July 29, 2019: member

    Hadn't noticed that this targeted a branch instead of master.

  15. MarcoFalke commented at 2:05 PM on July 29, 2019: member

    8e0720b is in all supported branches

  16. MarcoFalke locked this on Dec 16, 2021

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-17 03:14 UTC

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