Skip to content

Fix MSVC narrowing-conversion warnings (C4244/C4267) under /W3#1431

Merged
SGSSGene merged 1 commit intojbeder:masterfrom
benhillis:fix/msvc-narrowing-warnings
Apr 20, 2026
Merged

Fix MSVC narrowing-conversion warnings (C4244/C4267) under /W3#1431
SGSSGene merged 1 commit intojbeder:masterfrom
benhillis:fix/msvc-narrowing-warnings

Conversation

@benhillis
Copy link
Copy Markdown
Contributor

Add explicit casts to silence 8 warnings triggered by MSVC /W3:

fptostring.cpp:

  • Add static_cast(precision) where public API (size_t) calls internal template (int)
  • Add static_cast(...) for pointer-arithmetic result stored in int

dragonbox.h:

  • Add static_cast<uint_least32_t>(n) in umul64() calls inside if-constexpr branches guarded by is_same<UInt, uint_least32_t> to silence MSVC warnings on discarded branches when UInt=uint_least64_t
  • Change trailing-zero counter 's' from size_t to DecimalExponentType in both remove_trailing_zeros specializations to match exponent type

@SGSSGene
Copy link
Copy Markdown
Collaborator

Thank you for the contribution.

I just wanted to say I have the PR on my mind just not the time yet to check/merge it.

Add explicit casts to silence 8 warnings triggered by MSVC /W3:

fptostring.cpp:
- Add static_cast<int>(precision) where public API (size_t) calls
  internal template (int)
- Add static_cast<int>(...) for pointer-arithmetic result stored in int

dragonbox.h:
- Add static_cast<uint_least32_t>(n) in umul64() calls inside
  if-constexpr branches guarded by is_same<UInt, uint_least32_t> to
  silence MSVC warnings on discarded branches when UInt=uint_least64_t
- Change trailing-zero counter 's' from size_t to DecimalExponentType
  in both remove_trailing_zeros specializations to match exponent type

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@SGSSGene SGSSGene force-pushed the fix/msvc-narrowing-warnings branch from 32b109b to 1ecfeb8 Compare April 20, 2026 14:32
@SGSSGene SGSSGene merged commit fb91075 into jbeder:master Apr 20, 2026
46 checks passed
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.

2 participants