Big amount of -Wconversion warnings
raul-klg opened this issue · comments
raul-klg commented
Hello:
Thanks for this piece of software which I have found very helpful.
I use it in one of our projects where we happen to also use the -Wconversion gcc flag. When doing like this, a lot of warning are issued by the compiler. For instance:
In file included from ../../src/main.cpp:38:0:
../../../inc/CRC.h: In instantiation of ‘static CRCType CRC::CalculateRemainder(const void*, size_t, const CRC::Parameters<CRCType, CRCWidth>&, CRCType) [with CRCType = unsigned char; short unsigned int CRCWidth = 8u; size_t = long unsigned int]’:
../../../inc/CRC.h:438:43: required from ‘static CRCType CRC::Calculate(const void*, size_t, const CRC::Parameters<CRCType, CRCWidth>&) [with CRCType = unsigned char; short unsigned int CRCWidth = 8u; size_t = long unsigned int]’
../../src/main.cpp:102:41: required from ‘void CRCBitByBitTest(const char*, size_t, const CRC::Parameters<CRCType, CRCWidth>&, CRCType, const string&) [with CRCType = unsigned char; short unsigned int CRCWidth = 8u; size_t = long unsigned int; std::__cxx11::string = std::__cxx11::basic_string<char>]’
../../src/main.cpp:208:5: required from here
../../../inc/CRC.h:624:23: warning: conversion to ‘unsigned char’ from ‘int’ may alter its value [-Wconversion]
remainder ^= *current++;
~~~~~~~~~~^~~~~~~~~~~~~
Find attached the whole build log and a patch to reproduce the problem.
Steps to reproduce (on Debian Stretch but could work for other distros) :
- Clone the repository
- Apply patch
- go to test/prj/gcc subdirectory
- make
Daniel Bahr commented
Thanks for filing this issue; I was able to reproduce it. I'll have a fix shortly.
Daniel Bahr commented
Issue is fixed in master and will be included in release-1.0.0.0.