Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation warnings compiling with Microsoft Visual Studio Professional 2019 Version 16.8.0 (x86) #136

Open
alastairUK opened this issue Nov 11, 2020 · 1 comment

Comments

@alastairUK
Copy link

When building in 32 bit (x86) mode I see a whole load of warnings. Obviously I can disable but likely worth addressing.

csv.hpp(926,39): warning C4244: 'return': conversion from 'int64_t' to 'size_t', possible loss of data
csv.hpp(951,61): warning C4244: 'argument': conversion from 'const int64_t' to 'size_t', possible loss of data
csv.hpp(972,13): warning C4244: 'argument': conversion from 'const int64_t' to 'SIZE_T', possible loss of data
csv.hpp(6786,24): warning C4244: 'return': conversion from 'std::streamoff' to 'size_t', possible loss of data
csv.hpp(6139,39): warning C4244: '=': conversion from 'std::streamoff' to 'size_t', possible loss of data
csv.hpp(6127): message : while compiling class template member function 'void csv::internals::StreamParser<std::stringstream>::next(size_t)'
csv.hpp(7192): message : see reference to function template instantiation 'void csv::internals::StreamParser<std::stringstream>::next(size_t)' being compiled
csv.hpp(7190): message : see reference to class template instantiation 'csv::internals::StreamParser<std::stringstream>' being compiled
csv.hpp(6147,43): warning C4244: '=': conversion from 'std::streamoff' to 'size_t', possible loss of data
csv.hpp(570,29): warning C4244: 'argument': conversion from 'int64_t' to 'const mio::basic_mmap<mio::access_mode::read,char>::size_type', possible loss of data
csv.hpp(585): message : see reference to function template instantiation 'MMap mio::make_mmap<mio::mmap_source,MappingToken>(const MappingToken &,int64_t,int64_t,std::error_code &)' being compiled
1>        with
1>        [
1>            MMap=mio::mmap_source,
1>            MappingToken=std::string
1>        ]
csv.hpp(6798): message : see reference to function template instantiation 'mio::mmap_source mio::make_mmap_source<std::string>(const MappingToken &,mio::basic_mmap<mio::access_mode::read,char>::size_type,mio::basic_mmap<mio::access_mode::read,char>::size_type,std::error_code &)' being compiled
1>        with
1>        [
1>            MappingToken=std::string
1>        ]
csv.hpp(570,21): warning C4244: 'argument': conversion from 'int64_t' to 'const mio::basic_mmap<mio::access_mode::read,char>::size_type', possible loss of data
csv.hpp(1138,22): warning C4244: '=': conversion from 'const int64_t' to 'mio::basic_mmap<mio::access_mode::read,char>::size_type', possible loss of data
csv.hpp(1104): message : while compiling class template member function 'void mio::basic_mmap<mio::access_mode::read,char>::map(const mio::basic_mmap<mio::access_mode::read,char>::handle_type,const mio::basic_mmap<mio::access_mode::read,char>::size_type,const mio::basic_mmap<mio::access_mode::read,char>::size_type,std::error_code &)'
csv.hpp(1093): message : see reference to function template instantiation 'void mio::basic_mmap<mio::access_mode::read,char>::map(const mio::basic_mmap<mio::access_mode::read,char>::handle_type,const mio::basic_mmap<mio::access_mode::read,char>::size_type,const mio::basic_mmap<mio::access_mode::read,char>::size_type,std::error_code &)' being compiled
csv.hpp(1017): message : while compiling class template member function 'mio::basic_mmap<mio::access_mode::read,char>::basic_mmap(mio::basic_mmap<mio::access_mode::read,char> &&)'
csv.hpp(571): message : see reference to function template instantiation 'mio::basic_mmap<mio::access_mode::read,char>::basic_mmap(mio::basic_mmap<mio::access_mode::read,char> &&)' being compiled
csv.hpp(1181): message : while compiling class template member function 'void mio::basic_mmap<mio::access_mode::read,char>::unmap(void)'
csv.hpp(1012): message : see reference to function template instantiation 'void mio::basic_mmap<mio::access_mode::read,char>::unmap(void)' being compiled
csv.hpp(1010): message : while compiling class template member function 'mio::basic_mmap<mio::access_mode::read,char>::~basic_mmap(void)'
csv.hpp(6798): message : see reference to function template instantiation 'mio::basic_mmap<mio::access_mode::read,char>::~basic_mmap(void)' being compiled
csv.hpp(582): message : see reference to class template instantiation 'mio::basic_mmap<mio::access_mode::read,char>' being compiled
csv.hpp(1139,29): warning C4244: '=': conversion from 'const int64_t' to 'mio::basic_mmap<mio::access_mode::read,char>::size_type', possible loss of data
@macdew
Copy link

macdew commented Aug 5, 2021

I'm also getting a number of warnings in CSVField::try_parse_hex:

include\csv.hpp(7777,54): warning C4244: '+=': conversion from 'double' to 'unsigned __int64', possible loss of data
include\csv.hpp(7781,23): warning C4244: '=': conversion from 'unsigned __int64' to 'int', possible loss of data

the first one is caused by pow() returning a double that is then assigned to an unsigned long long. The second one is when the unsigned long long is assigned back to the result "int", which is another place where the result cannot hold the unsigned long long.

Probably easiest fix is to static_cast the result of pow back to an int, and not use unsigned long long when the end-result gets copied back into an int?

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

No branches or pull requests

2 participants