Skip to content

Fix AppVeyor failures from the Zmij double writer - #5843

Merged
nlohmann merged 1 commit into
developfrom
fix/appveyor-zmij-msvc
Oct 15, 2026
Merged

nlohmann merged 1 commit into
developfrom
fix/appveyor-zmij-msvc

Conversation

@nlohmann

Copy link
Copy Markdown
Owner

AppVeyor build 9193 on develop fails since #5634 (Zmij double writer):

  • VS2015 (all three jobs): zmij.hpp(187): warning C4554: '<<': check operator precedence — a false positive on (p.high << static_cast<unsigned>(64 - extra_shift)) | (p.low >> static_cast<unsigned>(extra_shift)) despite the parentheses; with /W4 /WX nothing builds. The shift amounts are now named constexpr unsigned constants, so the expression has no casts.
  • VS2017, C++17 shard 1/2 (x86 and x64): test-to_chars_cpp17 fails 16 checks at unit-to_chars.cpp:713, all for two-digit outputs (0.25, 16.0, 1.6e-322, …). The test built the one-digit-shorter candidates with std::scientific << std::setprecision(digits.size() - 2); MSVC 2017's library ignores a precision of 0, so the "shorter" candidate was the value itself. The test now truncates the digits instead: the value lies within half a unit of the last printed digit, so the truncated digits and their successor are the closest shorter candidates (the existing mid - 1, mid, mid + 1 loop keeps covering them). The now unused <iomanip>, <sstream>, <locale> includes are dropped.

Checked locally with clang (C++11 and C++17, -Wall -Wextra -Wconversion -Werror): the to_chars test passes with the same 623,597 assertions. Neither MSVC version is available locally, so AppVeyor confirms the fix.

Public API

No breaking changes: the library change only renames internal shift amounts in detail::zmij; output is unchanged.


Written by Claude Code.

🤖 Generated with Claude Code

MSVC 2015 warns C4554 on the shifts with casts in the fractional part
of zmij::to_shortest despite the parentheses; with /WX every target
fails to build. Name the shift amounts as constants instead.

The shortest-digits test built the candidates with one digit fewer via
a stream with std::setprecision(digits.size() - 2); the standard library
of MSVC 2017 ignores a precision of 0, so for two-digit values the
"shorter" candidates were the value itself. Truncate the digits
instead: the value lies within half a unit of the last digit, so the
truncated digits and their successor are the closest candidates.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
@nlohmann nlohmann added this to the Release 3.13.0 milestone Oct 15, 2026
@nlohmann nlohmann added the 🚀 ready to merge Ready to merge - just waiting for CI to complete. label Oct 15, 2026
@nlohmann
nlohmann merged commit b41228c into develop Oct 15, 2026
161 of 170 checks passed
@nlohmann
nlohmann deleted the fix/appveyor-zmij-msvc branch October 15, 2026 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

M 🚀 ready to merge Ready to merge - just waiting for CI to complete. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants