Skip to content

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

Open
benhillis wants to merge 1 commit intojbeder:masterfrom
benhillis:fix/msvc-narrowing-warnings
Open

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

Conversation

@benhillis
Copy link
Copy Markdown

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

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
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.

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