boostorg / locale

Boost.Locale
Boost Software License 1.0
32 stars 70 forks source link

Loss of data (C4244) warnings in MSVC 64-bit build #42

Closed SpareSimian closed 2 years ago

SpareSimian commented 5 years ago

Building with MSVC compilers for 64-bit results in several C4244 warnings in api.hpp, due to passing the difference of two pointers (ptrdiff_t) to Win APIs expecting an int. The attached patch adds casts to silence the warnings.

api.hpp.diff.txt

OlafvdSpek commented 5 years ago

C4244 is Loss of data, Loss of precision is a floating point thing.

OlafvdSpek commented 5 years ago

Wouldn't a runtime check on size < 2GB be required as well?

SpareSimian commented 5 years ago

Issue title corrected, thanks.

We could certainly put an assert in there to check the size argument. This is really a case of Windows using the wrong type, but it's probably necessary for compatibility. I suggest a test against std::numeric_limits::max(), which would probably get optimized away if int is the same size as ptrdiff_t.

Flamefire commented 2 years ago

Fixed by #86