msvc compile broken by new varint encoding checks #12732

issue sipsorcery opened this issue on March 20, 2018
  1. sipsorcery commented at 3:19 AM on March 20, 2018: member

    The commit for #9573 has broken the ability to compile libbitcoin_server and the test and bench programs.

    The compiler error is:

    Error C2338 Signed type required with mode NONNEGATIVE_SIGNED. libbitcoin_server f:\dev\github\bitcoin-msvc\src\serialize.h 316

    It looks like the static_assert in serialize.h is now more aggressively checking inputs. I've tracked down one of the static_assert triggers to a change from the same commit in blockchain.cpp line 838:

    ss << VARINT(outputs.begin()->second.nHeight * 2 + outputs.begin()->second.fCoinBase, VarIntMode::NONNEGATIVE_SIGNED);

    Changing the VarIntMode to DEFAULT removes one of the errors. From my inspection the two fields being encoded are both uint's so shouldn't need the NONNEGATIVE_SIGNED mode (of course that may be different with non-msvc compilers):

    outputs.begin()->second.nHeight is uint32_t outputs.begin()->second.fCoinBase is unsigned int

    I'm not really sure what the best approach to fix this is but am happy to do any further investigation if required.

  2. fanquake added the label Windows on Mar 20, 2018
  3. ryanofsky referenced this in commit e491b96ea2 on Mar 20, 2018
  4. ryanofsky commented at 5:13 PM on March 20, 2018: member

    Can you try #12737 which removes the use of NONNEGATIVE_SIGNED here?

    It seems fCoinBase is treated like a signed value on linux but an unsigned value on windows. #12737 makes it unsigned in all cases.

  5. ryanofsky referenced this in commit 34ca750320 on Mar 20, 2018
  6. sipa referenced this in commit 9b8b1079dd on Mar 21, 2018
  7. fanquake commented at 3:01 AM on March 21, 2018: member

    Should be fixed by #12737.

  8. fanquake closed this on Mar 21, 2018

  9. HashUnlimited referenced this in commit 4d56dec88c on Jul 31, 2018
  10. lionello referenced this in commit 254b9de779 on Nov 7, 2018
  11. furszy referenced this in commit dc37dd9e07 on Mar 21, 2021
  12. PastaPastaPasta referenced this in commit 032593d047 on Apr 13, 2021
  13. xdustinface referenced this in commit b42032d3a8 on Apr 13, 2021
  14. DrahtBot locked this on Sep 8, 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-13 21:15 UTC

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