d-bahr/CRCpp

warning: left shift count >= width of type

raul-klg opened this issue · 3 comments

Hello:
After fixing #3 (thanks for that), I'm now noticing the subject warning:

../../../inc/CRC.h:753:52: warning: left shift count >= width of type [-Wshift-count-overflow]
         remainder = static_cast<CRCType>(remainder << SHIFT);

In order to reproduce I clone and update to HEAD (7421f32). I then go to test/prj/gcc and finally I issue make.
I'm on debian stretch and gcc version is:

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 6.3.0-18+deb9u1' --with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-6 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-6-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 6.3.0 20170516 (Debian 6.3.0-18+deb9u1)

build.log

Weird, this only happens with GCC 6, but GCC 7 compiles without errors. The BoundedConstexprValue function should trap these errors, but maybe there's something odd with how GCC 6 handles constexpr functions.

Try HEAD now (534c1d8) and let me know if you still have any issues.

Note to self, this probably should be fixed by properly supporting SFINAE but getting cross-compilation support with SFINAE is probably pretty painful.

Ticket has been idle for a while, a fix has been committed, so I'm going to close this issue.