cast from 'ILubyte* {aka unsigned char*}' to 'ILint {aka int}' loses precision
klausenbusk opened this issue · 3 comments
klausenbusk commented
Hello
I get the following, when trying to compile DevIL from ArchLinux.
git clone git@github.com:DentonW/DevIL.git
cd DevIL/DevIL
cmake .
make
[ 1%] Building CXX object src-IL/CMakeFiles/IL.dir/src/il_rle.cpp.o
/home/kristian/Hentninger/DevIL/DevIL/src-IL/src/il_rle.cpp: In function 'ILboolean ilRleCompressLine(ILubyte*, ILuint, ILubyte, ILubyte*, ILuint*, ILenum)':
/home/kristian/Hentninger/DevIL/DevIL/src-IL/src/il_rle.cpp:20:52: error: cast from 'ILubyte* {aka unsigned char*}' to 'ILint {aka int}' loses precision [-fpermissive]
const ILint bmp_pad_to_even = (ILint)(1 - ((ILint)q - *DestWidth) % 2);
^
make[2]: *** [src-IL/CMakeFiles/IL.dir/build.make:1479: src-IL/CMakeFiles/IL.dir/src/il_rle.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:86: src-IL/CMakeFiles/IL.dir/all] Error 2
make: *** [Makefile:128: all] Error 2
Removing the q
, seems to fix it, but I'm not sure if that yields other problems?
Regards Kristian
andrewmcwatters commented
I'm also experiencing this issue in master
247fd43
from macOS.
Thanks for all your hard work, Denton!
andrewmcwatters commented
Error
[ 1%] Building CXX object src-IL/CMakeFiles/IL.dir/src/il_rle.cpp.o
/Users/andrewmcwatters/DevIL/DevIL/src-IL/src/il_rle.cpp:20:45: error: cast from
pointer to smaller type 'ILint' (aka 'int') loses information
const ILint bmp_pad_to_even = (ILint)(1 - ((ILint)q - *DestWidth) % 2);
^~~~~~~~
1 error generated.
make[2]: *** [src-IL/CMakeFiles/IL.dir/src/il_rle.cpp.o] Error 1
make[1]: *** [src-IL/CMakeFiles/IL.dir/all] Error 2
make: *** [all] Error 2
Fix
/Users/andrewmcwatters/DevIL/DevIL/src-IL/src/il_rle.cpp:20:45
const ILint bmp_pad_to_even = (ILint)(1 - ((ILint)q - *DestWidth) % 2);
const ILint bmp_pad_to_even = (ILint)(1 - ((ILint)(size_t)q - *DestWidth) % 2);
References
Result
DevIL successfully compiles.
DentonW commented
Thanks, Visual Studio complained about that when compiling 64-bit but just gave a warning. I just committed your change.