Mahlet-Inc / hobbits

A multi-platform GUI for bit-based analysis, processing, and visualization
https://mahlet-inc.github.io
MIT License
660 stars 45 forks source link

error: narrowing conversion of ‘-128’ from ‘int’ to ‘char’ [-Wnarrowing] #173

Open andreas-schwab opened 4 months ago

andreas-schwab commented 4 months ago

[ 5%] Building CXX object src/hobbits-core/CMakeFiles/hobbits-core.dir/bitarray.cpp.o cd /home/abuild/rpmbuild/BUILD/hobbits-0.54.1/build/src/hobbits-core && /usr/bin/c++ -DHOBBITSCORE_LIBRARY -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DQT_WIDGETS_LIB -Dhobbits_core_EXPORTS -I/home/abuild/rpmbuild/BUILD/hobbits-0.54.1/build/src/hobbits-core/hobbits-core_autogen/include -isystem /usr/include/qt5 -isystem /usr/include/qt5/QtCore -isystem /usr/lib64/qt5/mkspecs/linux-g++ -isystem /usr/include/qt5/QtWidgets -isystem /usr/include/qt5/QtGui -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -g -fno-sized-deallocation -O2 -g -DNDEBUG -std=gnu++11 -fPIC -fPIC -MD -MT src/hobbits-core/CMakeFiles/hobbits-core.dir/bitarray.cpp.o -MF CMakeFiles/hobbits-core.dir/bitarray.cpp.o.d -o CMakeFiles/hobbits-core.dir/bitarray.cpp.o -c /home/abuild/rpmbuild/BUILD/hobbits-0.54.1/src/hobbits-core/bitarray.cpp /home/abuild/rpmbuild/BUILD/hobbits-0.54.1/src/hobbits-core/bitarray.cpp:23:5: error: narrowing conversion of ‘-128’ from ‘int’ to ‘char’ [-Wnarrowing] 23 | -128, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 | ^~~~ /home/abuild/rpmbuild/BUILD/hobbits-0.54.1/src/hobbits-core/bitarray.cpp:27:11: error: narrowing conversion of ‘-65’ from ‘int’ to ‘char’ [-Wnarrowing] 27 | 0x7f, -65, -33, -17, -9, -5, -3, -2 | ^~~ /home/abuild/rpmbuild/BUILD/hobbits-0.54.1/src/hobbits-core/bitarray.cpp:27:16: error: narrowing conversion of ‘-33’ from ‘int’ to ‘char’ [-Wnarrowing] 27 | 0x7f, -65, -33, -17, -9, -5, -3, -2 | ^~~ /home/abuild/rpmbuild/BUILD/hobbits-0.54.1/src/hobbits-core/bitarray.cpp:27:21: error: narrowing conversion of ‘-17’ from ‘int’ to ‘char’ [-Wnarrowing] 27 | 0x7f, -65, -33, -17, -9, -5, -3, -2 | ^~~ /home/abuild/rpmbuild/BUILD/hobbits-0.54.1/src/hobbits-core/bitarray.cpp:27:26: error: narrowing conversion of ‘-9’ from ‘int’ to ‘char’ [-Wnarrowing] 27 | 0x7f, -65, -33, -17, -9, -5, -3, -2 | ^~ /home/abuild/rpmbuild/BUILD/hobbits-0.54.1/src/hobbits-core/bitarray.cpp:27:30: error: narrowing conversion of ‘-5’ from ‘int’ to ‘char’ [-Wnarrowing] 27 | 0x7f, -65, -33, -17, -9, -5, -3, -2 | ^~ /home/abuild/rpmbuild/BUILD/hobbits-0.54.1/src/hobbits-core/bitarray.cpp:27:34: error: narrowing conversion of ‘-3’ from ‘int’ to ‘char’ [-Wnarrowing] 27 | 0x7f, -65, -33, -17, -9, -5, -3, -2 | ^~ /home/abuild/rpmbuild/BUILD/hobbits-0.54.1/src/hobbits-core/bitarray.cpp:27:38: error: narrowing conversion of ‘-2’ from ‘int’ to ‘char’ [-Wnarrowing] 27 | 0x7f, -65, -33, -17, -9, -5, -3, -2 | ^~ /home/abuild/rpmbuild/BUILD/hobbits-0.54.1/src/hobbits-core/bitarray.cpp: In member function ‘QString BitArray::toBin(qint64, int) const’: /home/abuild/rpmbuild/BUILD/hobbits-0.54.1/src/hobbits-core/bitarray.cpp:834:35: warning: comparison of integer expressions of different signedness: ‘quint64’ {aka ‘long long unsigned int’} and ‘qint64’ {aka ‘long long int’} [-Wsign-compare] 834 | for (quint64 i = start; i < start + length; i ++) { | ^~~~~~ /home/abuild/rpmbuild/BUILD/hobbits-0.54.1/src/hobbits-core/bitarray.cpp: In member function ‘QString BitArray::toHex(qint64, int) const’: /home/abuild/rpmbuild/BUILD/hobbits-0.54.1/src/hobbits-core/bitarray.cpp:849:37: warning: comparison of integer expressions of different signedness: ‘quint64’ {aka ‘long long unsigned int’} and ‘qint64’ {aka ‘long long int’} [-Wsign-compare] 849 | for (quint64 i = start4; i < start4+length*4; i += 4) { | ^~~~ make[2]: *** [src/hobbits-core/CMakeFiles/hobbits-core.dir/build.make:142: src/hobbits-core/CMakeFiles/hobbits-core.dir/bitarray.cpp.o] Error 1

ggardet commented 3 months ago

You likely need to switch from char to signed char. Especially for aarch64 and likely other architectures.

hello-adam commented 3 months ago

ah, ok, thanks for the tip, I was not sure how to reproduce this. I'll go give that a shot.

hello-adam commented 3 months ago

@andreas-schwab does it work with this -fsigned-char patch? 5a528ec7750fc846ea162edcc1797218088ffbd6

andreas-schwab commented 3 months ago

-fsigned-char breaks the ABI.

hello-adam commented 3 months ago

Hmm, I guess if the only problem is those masks, they could be redefined in a more compatible way.