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

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

Open
andreas-schwab opened this issue May 4, 2024 · 5 comments

Comments

@andreas-schwab
Copy link

[ 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
Copy link

ggardet commented Jun 7, 2024

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

@hello-adam
Copy link
Member

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

@hello-adam
Copy link
Member

hello-adam commented Jun 7, 2024

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

@andreas-schwab
Copy link
Author

andreas-schwab commented Jun 7, 2024 via email

@hello-adam
Copy link
Member

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

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

3 participants