MSVC warnings in the new glz::to_chars implementation
The following code snippet:
```cpp
#include <iostream>
#include <glaze/util/zmij.hpp>
int main()
{
char buff[10]{};
glz::to_chars(buff, 10.f);
std::cout << buff << '\n';
return 0;
}
```
compiled under VS2026 v.18.5.0 using glaze v7.5.0 produces the following litany of warning:
```
1> main.cpp
1>glaze\util\zmij.hpp(446,41): error C2220: the following warning is treated as an error
1> (compiling source file 'main.cpp')
1>glaze\util\zmij.hpp(446,41): warning C4244: 'return': conversion from 'int' to 'unsigned char', possible loss of data
1> (compiling source file 'main.cpp')
1>glaze\util\zmij.hpp(527,40): warning C4244: '=': conversion from 'int' to 'unsigned char', possible loss of data
1> (compiling source file 'main.cpp')
1>glaze\util\zmij.hpp(528,40): warning C4244: '=': conversion from 'int' to 'unsigned char', possible loss of data
1> (compiling source file 'main.cpp')
1>glaze\util\zmij.hpp(533,41): warning C4244: '=': conversion from 'int' to 'unsigned char', possible loss of data
1> (compiling source file 'main.cpp')
1>glaze\util\zmij.hpp(535,57): warning C4244: '=': conversion from 'int' to 'unsigned char', possible loss of data
1> (compiling source file 'main.cpp')
1>glaze\util\zmij.hpp(537,47): warning C4244: '=': conversion from 'int' to 'unsigned char', possible loss of data
1> (compiling source file 'main.cpp')
1>glaze\util\zmij.hpp(603,47): warning C4244: 'initializing': conversion from 'double' to 'const uint64_t', possible loss of data
1> (compiling source file 'main.cpp')
1> glaze\util\zmij.hpp(603,47):
1> the template instantiation context (the oldest one first) is
1> E:\Projects\paszklar\cpp_testing\cpp_testing\main.cpp(6,10):
1> see reference to function template instantiation 'char *glz::to_chars<float,false>(char *,T) noexcept' being compiled
1> with
1> [
1> T=float
1> ]
1> glaze\util\zmij.hpp(1077,28):
1> see reference to function template instantiation 'char *glz::zmij::detail::write<float,false>(Float,char *) noexcept' being compiled
1> with
1> [
1> Float=float
1> ]
1> glaze\util\zmij.hpp(948,27):
1> see reference to variable template 'const glz::zmij::detail_impl::constants<false> consts_v<0>' being compiled
1> glaze\util\zmij.hpp(635,55):
1> see reference to class template instantiation 'glz::zmij::detail_impl::constants<false>' being compiled
1>glaze\util\zmij.hpp(632,1): warning C4324: 'glz::zmij::detail_impl::constants<false>': structure was padded due to alignment specifier
1> (compiling source file 'main.cpp')
1>glaze\util\zmij.hpp(974,28): warning C4018: '<': signed/unsigned mismatch
1> (compiling source file 'main.cpp')
1>glaze\util\zmij.hpp(979,28): warning C4244: 'initializing': conversion from '__int64' to 'int', possible loss of data
1> (compiling source file 'main.cpp')
1>glaze\util\zmij.hpp(986,37): warning C4018: '>=': signed/unsigned mismatch
1> (compiling source file 'main.cpp')
1>glaze\util\zmij.hpp(1003,54): warning C4244: '=': conversion from 'int' to 'char', possible loss of data
1> (compiling source file 'main.cpp')
1>glaze\util\zmij.hpp(1011,33): warning C4244: '=': conversion from 'int' to 'char', possible loss of data
1> (compiling source file 'main.cpp')
1>glaze\util\zmij.hpp(1035,28): warning C4244: 'initializing': conversion from 'unsigned __int64' to 'uint32_t', possible loss of data
1> (compiling source file 'main.cpp')
1>glaze\util\zmij.hpp(1037,27): warning C4244: '=': conversion from 'uint32_t' to 'char', possible loss of data
1> (compiling source file 'main.cpp')
1>glaze\util\zmij.hpp(845,107): warning C4244: 'argument': conversion from 'int64_t' to 'int', possible loss of data
1> (compiling source file 'main.cpp')
1> glaze\util\zmij.hpp(845,107):
1> the template instantiation context (the oldest one first) is
1> glaze\util\zmij.hpp(1077,28):
1> see reference to function template instantiation 'char *glz::zmij::detail::write<float,false>(Float,char *) noexcept' being compiled
1> with
1> [
1> Float=float
1> ]
1> glaze\util\zmij.hpp(971,32):
1> see reference to function template instantiation 'glz::zmij::detail_impl::to_decimal_result glz::zmij::detail_impl::to_decimal<float,unsigned int,false>(UInt,int64_t,bool,const glz::zmij::detail_impl::constants<false> &) noexcept' being compiled
1> with
1> [
1> UInt=unsigned int
1> ]
1>glaze\util\zmij.hpp(844,22): warning C4244: 'initializing': conversion from 'unsigned __int64' to 'int', possible loss of data
1> (compiling source file 'main.cpp')
1>glaze\util\zmij.hpp(850,17): warning C4456: declaration of 'dec_exp' hides previous local declaration
1> (compiling source file 'main.cpp')
1> glaze\util\zmij.hpp(844,14):
1> see declaration of 'dec_exp'
1>glaze\util\zmij.hpp(850,43): warning C4244: 'argument': conversion from 'int64_t' to 'int', possible loss of data
1> (compiling source file 'main.cpp')
1>glaze\util\zmij.hpp(851,53): warning C4244: 'argument': conversion from 'int64_t' to 'int', possible loss of data
1> (compiling source file 'main.cpp')
1>glaze\util\zmij.hpp(870,27): warning C4456: declaration of 'extra_shift' hides previous local declaration
1> (compiling source file 'main.cpp')
1> glaze\util\zmij.hpp(847,24):
1> see declaration of 'extra_shift'
1>glaze\util\zmij.hpp(871,53): warning C4244: 'argument': conversion from 'int64_t' to 'int', possible loss of data
1> (compiling source file 'main.cpp')
1>glaze\util\zmij.hpp(892,55): warning C4244: 'argument': conversion from 'int64_t' to 'int', possible loss of data
1> (compiling source file 'main.cpp')
```
This seems quite a regression, since from my experience so far the library compiled cleanly even with `/W4 /WX`.
关闭于 2026-05-10 5 条评论