Skip to content

msvc compile broken by new varint encoding checks #12732

@sipsorcery

Description

@sipsorcery

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions