The warning I get is below. We do not use wide characters in our code base. I have warnings treated as errors so the fmt library is causing builds to fail. I'm using latest in master as of today and my version of Visual Studio is 15.6.4
1>e:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.13.26128\include\memory(29): note: see reference to function template instantiation 'void std::_Construct_in_place<T,const Char&>(_Ty &,const Char &) noexcept' being compiled
1> with
1> [
1> T=char,
1> Char=wchar_t,
1> _Ty=char
1> ]
1>e:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.13.26128\include\memory(59): note: see reference to function template instantiation '_FwdIt *std::_Uninitialized_copy_unchecked<_Iter,char*>(_InIt,_InIt,_FwdIt,std::_General_ptr_iterator_tag)' being compiled
1> with
1> [
1> _FwdIt=char *,
1> _Iter=const wchar_t *,
1> _InIt=const wchar_t *
1> ]
1>e:\code\frontend2\source\core\thirdparty\fmt\include\fmt\format.h(956): note: see reference to function template instantiation '_FwdIt std::uninitialized_copy<const Char*,stdext::checked_array_iterator<T *>>(_InIt,_InIt,_FwdIt)' being compiled
1> with
1> [
1> _FwdIt=stdext::checked_array_iterator<char *>,
1> Char=wchar_t,
1> T=char,
1> _InIt=const wchar_t *
1> ]
1>e:\code\frontend2\source\core\thirdparty\fmt\include\fmt\format.h(978): note: see reference to function template instantiation 'void fmt::internal::add_thousands_sep<wchar_t>::operator ()<Char>(BufChar *&)' being compiled
1> with
1> [
1> Char=char,
1> BufChar=char
1> ]
1>e:\code\frontend2\source\core\thirdparty\fmt\include\fmt\format.h(978): note: see reference to function template instantiation 'void fmt::internal::add_thousands_sep<wchar_t>::operator ()<Char>(BufChar *&)' being compiled
1> with
1> [
1> Char=char,
1> BufChar=char
1> ]
1>e:\code\frontend2\source\core\thirdparty\fmt\include\fmt\format.h(998): note: see reference to function template instantiation 'Char *fmt::internal::format_decimal<UInt,char,ThousandsSep>(Char *,UInt,unsigned int,ThousandsSep)' being compiled
1> with
1> [
1> Char=char,
1> UInt=unsigned int,
1> ThousandsSep=fmt::internal::add_thousands_sep<wchar_t>
1> ]
1>e:\code\frontend2\source\core\thirdparty\fmt\include\fmt\format.h(2511): note: see reference to function template instantiation 'Iterator fmt::internal::format_decimal<unsigned int,It,fmt::internal::add_thousands_sep<wchar_t>>(Iterator,UInt,unsigned int,ThousandsSep)' being compiled
1> with
1> [
1> Iterator=stdext::checked_array_iterator<wchar_t *>,
1> It=stdext::checked_array_iterator<wchar_t *>,
1> UInt=unsigned int,
1> ThousandsSep=fmt::internal::add_thousands_sep<wchar_t>
1> ]
1>e:\code\frontend2\source\core\thirdparty\fmt\include\fmt\format.h(2349): note: see reference to function template instantiation 'void fmt::basic_writer<fmt::back_insert_range<fmt::internal::wbuffer>>::int_writer<T,Spec>::num_writer::operator ()<It&>(stdext::checked_array_iterator<wchar_t *>&) const' being compiled
1> with
1> [
1> T=uintptr_t,
1> Spec=fmt::basic_format_specs<wchar_t>,
1> It=stdext::checked_array_iterator<wchar_t *>
1> ]
1>e:\code\frontend2\source\core\thirdparty\fmt\include\fmt\format.h(2349): note: see reference to function template instantiation 'void fmt::basic_writer<fmt::back_insert_range<fmt::internal::wbuffer>>::int_writer<T,Spec>::num_writer::operator ()<It&>(stdext::checked_array_iterator<wchar_t *>&) const' being compiled
1> with
1> [
1> T=uintptr_t,
1> Spec=fmt::basic_format_specs<wchar_t>,
1> It=stdext::checked_array_iterator<wchar_t *>
1> ]
1>e:\code\frontend2\source\core\thirdparty\fmt\include\fmt\format.h(2685): note: see reference to function template instantiation 'void fmt::basic_writer<fmt::back_insert_range<fmt::internal::wbuffer>>::padded_int_writer<F>::operator ()<stdext::checked_array_iterator<T *>>(It &&) const' being compiled
1> with
1> [
1> F=fmt::basic_writer<fmt::back_insert_range<fmt::internal::wbuffer>>::int_writer<uintptr_t,fmt::basic_format_specs<wchar_t>>::num_writer,
1> T=wchar_t,
1> It=stdext::checked_array_iterator<wchar_t *>
1> ]
1>e:\code\frontend2\source\core\thirdparty\fmt\include\fmt\format.h(2685): note: see reference to function template instantiation 'void fmt::basic_writer<fmt::back_insert_range<fmt::internal::wbuffer>>::padded_int_writer<F>::operator ()<stdext::checked_array_iterator<T *>>(It &&) const' being compiled
1> with
1> [
1> F=fmt::basic_writer<fmt::back_insert_range<fmt::internal::wbuffer>>::int_writer<uintptr_t,fmt::basic_format_specs<wchar_t>>::num_writer,
1> T=wchar_t,
1> It=stdext::checked_array_iterator<wchar_t *>
1> ]
1>e:\code\frontend2\source\core\thirdparty\fmt\include\fmt\format.h(2375): note: see reference to function template instantiation 'void fmt::basic_writer<fmt::back_insert_range<fmt::internal::wbuffer>>::write_padded<fmt::basic_writer<fmt::back_insert_range<fmt::internal::wbuffer>>::padded_int_writer<F>>(::size_t,const fmt::align_spec &,fmt::basic_writer<fmt::back_insert_range<fmt::internal::wbuffer>>::padded_int_writer<F>)' being compiled
1> with
1> [
1> F=fmt::basic_writer<fmt::back_insert_range<fmt::internal::wbuffer>>::int_writer<uintptr_t,fmt::basic_format_specs<wchar_t>>::num_writer
1> ]
1>e:\code\frontend2\source\core\thirdparty\fmt\include\fmt\format.h(2375): note: see reference to function template instantiation 'void fmt::basic_writer<fmt::back_insert_range<fmt::internal::wbuffer>>::write_padded<fmt::basic_writer<fmt::back_insert_range<fmt::internal::wbuffer>>::padded_int_writer<F>>(::size_t,const fmt::align_spec &,fmt::basic_writer<fmt::back_insert_range<fmt::internal::wbuffer>>::padded_int_writer<F>)' being compiled
1> with
1> [
1> F=fmt::basic_writer<fmt::back_insert_range<fmt::internal::wbuffer>>::int_writer<uintptr_t,fmt::basic_format_specs<wchar_t>>::num_writer
1> ]
1>e:\code\frontend2\source\core\thirdparty\fmt\include\fmt\format.h(2520): note: see reference to function template instantiation 'void fmt::basic_writer<fmt::back_insert_range<fmt::internal::wbuffer>>::write_int<Spec,fmt::basic_writer<fmt::back_insert_range<fmt::internal::wbuffer>>::int_writer<T,Spec>::num_writer>(unsigned int,fmt::string_view,const Spec &,F)' being compiled
1> with
1> [
1> Spec=fmt::basic_format_specs<wchar_t>,
1> T=uintptr_t,
1> F=fmt::basic_writer<fmt::back_insert_range<fmt::internal::wbuffer>>::int_writer<uintptr_t,fmt::basic_format_specs<wchar_t>>::num_writer
1> ]
1>e:\code\frontend2\source\core\thirdparty\fmt\include\fmt\format.h(2519): note: see reference to function template instantiation 'void fmt::basic_writer<fmt::back_insert_range<fmt::internal::wbuffer>>::write_int<Spec,fmt::basic_writer<fmt::back_insert_range<fmt::internal::wbuffer>>::int_writer<T,Spec>::num_writer>(unsigned int,fmt::string_view,const Spec &,F)' being compiled
1> with
1> [
1> Spec=fmt::basic_format_specs<wchar_t>,
1> T=uintptr_t,
1> F=fmt::basic_writer<fmt::back_insert_range<fmt::internal::wbuffer>>::int_writer<uintptr_t,fmt::basic_format_specs<wchar_t>>::num_writer
1> ]
1>e:\code\frontend2\source\core\thirdparty\fmt\include\fmt\format.h(2515): note: while compiling class template member function 'void fmt::basic_writer<fmt::back_insert_range<fmt::internal::wbuffer>>::int_writer<T,Spec>::on_num(void)'
1> with
1> [
1> T=uintptr_t,
1> Spec=fmt::basic_format_specs<wchar_t>
1> ]
1>e:\code\frontend2\source\core\thirdparty\fmt\include\fmt\format.h(1258): note: see reference to function template instantiation 'void fmt::basic_writer<fmt::back_insert_range<fmt::internal::wbuffer>>::int_writer<T,Spec>::on_num(void)' being compiled
1> with
1> [
1> T=uintptr_t,
1> Spec=fmt::basic_format_specs<wchar_t>
1> ]
1>e:\code\frontend2\source\core\thirdparty\fmt\include\fmt\format.h(2532): note: see reference to class template instantiation 'fmt::basic_writer<fmt::back_insert_range<fmt::internal::wbuffer>>::int_writer<T,Spec>' being compiled
1> with
1> [
1> T=uintptr_t,
1> Spec=fmt::basic_format_specs<wchar_t>
1> ]
1>e:\code\frontend2\source\core\thirdparty\fmt\include\fmt\format.h(1444): note: see reference to function template instantiation 'void fmt::basic_writer<fmt::back_insert_range<fmt::internal::wbuffer>>::write_int<uintptr_t,fmt::basic_format_specs<wchar_t>>(T,const Spec &)' being compiled
1> with
1> [
1> T=uintptr_t,
1> Spec=fmt::basic_format_specs<wchar_t>
1> ]
1>e:\code\frontend2\source\core\thirdparty\fmt\include\fmt\format.h(1444): note: see reference to function template instantiation 'void fmt::basic_writer<fmt::back_insert_range<fmt::internal::wbuffer>>::write_int<uintptr_t,fmt::basic_format_specs<wchar_t>>(T,const Spec &)' being compiled
1> with
1> [
1> T=uintptr_t,
1> Spec=fmt::basic_format_specs<wchar_t>
1> ]
1>e:\code\frontend2\source\core\thirdparty\fmt\include\fmt\format.h(1441): note: while compiling class template member function 'void fmt::internal::arg_formatter_base<Range>::write_pointer(const void *)'
1> with
1> [
1> Range=range
1> ]
1>e:\code\frontend2\source\core\thirdparty\fmt\include\fmt\format.h(1533): note: see reference to function template instantiation 'void fmt::internal::arg_formatter_base<Range>::write_pointer(const void *)' being compiled
1> with
1> [
1> Range=range
1> ]
1>e:\code\frontend2\source\core\thirdparty\fmt\include\fmt\format.h(2210): note: see reference to class template instantiation 'fmt::internal::arg_formatter_base<Range>' being compiled
1> with
1> [
1> Range=range
1> ]
1>e:\code\frontend2\source\core\thirdparty\fmt\include\fmt\format.h(3388): note: see reference to class template instantiation 'fmt::arg_formatter<range>' being compiled
1>e:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.13.26128\include\xmemory0(227): warning C4244: 'initializing': conversion from 'const wchar_t' to 'char', possible loss of data
Looks like I reported this a while back (issue #678). However it was stated there that this was not a fmtlib warning. This is not true, this is absolutely a warning caused by fmtlib.
And my usage of fmt:
throw std::runtime_error{
fmt::format("EVP_PKEY_CTX_new_id() failed with id: {}", m_type->Id())};
EDIT: Actually when I comment out the usage, the warning still appears. With no usage whatsoever, I get the warning, simply by having the header file (#include <fmt/format.h>) included.
I have the same warning, with VS 2017 15.5.6
Can confirm that is triggered including fmt/format.h
Thanks
bumb (me getting this, too on master).
Thanks for reporting. I don't see this particular warning, but a bunch of MSVC warnings have been fixed recently. Do you still see this on the latest master branch (https://github.com/fmtlib/fmt/commit/48ae0506de166a2915257f01bb135cebf3f907ce)?
I can confirm that with latest branch and VS 2017 15.5.6, I get no warnings.
Thanks
Thanks for confirmation, closing now. @rcdailey, feel free to reopen if you still see some warnings.
Most helpful comment
I have the same warning, with VS 2017 15.5.6
Can confirm that is triggered including fmt/format.h
Thanks