Skip to content

btc: disambiguate HexStr overload for MSVC (share_tracker.hpp:551) — last coin for all-5 Windows v0.2.1 - #711

Merged
frstrtr merged 1 commit into
masterfrom
btc/hexstr-msvc-disambig
Jul 15, 2026
Merged

btc: disambiguate HexStr overload for MSVC (share_tracker.hpp:551) — last coin for all-5 Windows v0.2.1#711
frstrtr merged 1 commit into
masterfrom
btc/hexstr-msvc-disambig

Conversation

@frstrtr

@frstrtr frstrtr commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Problem

BTC is the only coin missing from the v0.2.1 Windows set. c2pool-btc fails on MSVC:

src/impl/btc/share_tracker.hpp(551,29): error C2668: ambiguous call to overloaded function HexStr

s->m_address is a BaseScript whose m_data is std::vector<unsigned char>. MSVCs stricter overload resolution finds that vector viable for all three HexStr span overloads (Span<const uint8_t>, Span<const char>, Span<const std::byte>), so the bare HexStr(s->m_address.m_data) call is ambiguous. GCC/Clang resolve it, so Linux/macOS already build.

Fix

Name the exact parameter type of the intended overload — Span<const uint8_t> built from the raw byte span:

miner = HexStr(Span<const uint8_t>(s->m_address.m_data.data(), s->m_address.m_data.size()));

Span (btclibs/span.h) is already in scope via strencodings.h — no new include. This is MSVC-only disambiguation; no behavior change on any platform.

Output verified byte-identical

Minimal TU under -std=c++20 exercising the exact expression on a fixture:

  • HexStr(Span<const uint8_t>(data, size)) == HexStr(MakeUCharSpan(vec)) == deadbeef. rc=0.

Same bytes to the same uint8_t-span overload GCC/Clang were already selecting → the miner-id hex string is unchanged.

Mirrors the explicit-span idiom already green on the LTC Windows build (ltc/coin/template_builder.hpp).

std::vector<unsigned char> (m_address.m_data) is a viable argument for all
three HexStr span overloads (const uint8_t / const char / const std::byte)
under MSVC.stricter overload resolution, causing C2668 ambiguous-call on the
Windows build (GCC/Clang resolve it). Name the exact parameter type of the
intended overload, Span<const uint8_t>, built from the raw byte span.

Output is byte-identical to the prior GCC/Clang resolution (same bytes to the
same uint8_t-span overload); verified against MakeUCharSpan on a fixture.
Mirrors the explicit-span idiom already green on the LTC Windows build.
@frstrtr
frstrtr merged commit 73bb7bf into master Jul 15, 2026
24 of 26 checks passed
frstrtr added a commit that referenced this pull request Jul 16, 2026
MSVC C2668: HexStr(std::vector<unsigned char>) is viable for all three
Span overloads (uint8_t/char/std::byte). This is the SAME ambiguity #711
fixed in share_tracker.hpp, at a second call site the block-submit
fallback path uses. Feed the exact Span<const uint8_t> the intended
overload wants, matching the #711 pattern byte-for-byte.

Swept all HexStr call sites reachable from the MSVC btc build: the only
other bare-container sites (config_coin prefix, config_pool m_prefix) are
std::vector<std::byte>, which match a single overload and are already
unambiguous. No third site remains.

Co-authored-by: frstrtr <frstrtr@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant