vbindiff icon indicating copy to clipboard operation
vbindiff copied to clipboard

some gcc7 warnings

Open dodona2 opened this issue 8 years ago • 5 comments

just for the case it is not known:

vbindiff.cpp: In member function ‘void FileDisplay::setByte(short int, short int, Byte)’: vbindiff.cpp:635:6: warning: ‘%02X’ directive writing between 2 and 8 bytes into a region of size 3 [-Wformat-overflow=] void FileDisplay::setByte(short x, short y, Byte b) ^~~~~~~~~~~ vbindiff.cpp:635:6: note: directive argument in the range [0, 2147483647] vbindiff.cpp:659:12: note: ‘sprintf’ output between 3 and 9 bytes into a destination of size 3 sprintf(str, "%02X", b);

dodona2 avatar Sep 28 '17 19:09 dodona2

Any idea why gcc7 thinks that b is between 0 and 2147483647? It's unsigned char.

nfllab avatar Oct 05 '17 22:10 nfllab

the format string expects a long, and b is promoted to int. iirc :)

mrdudz avatar Oct 05 '17 22:10 mrdudz

'the format string expects a long, and b is promoted to int. iirc :)' can someone please fix ithis?

dodona2 avatar Oct 06 '17 08:10 dodona2

Let's hope the gcc developers will fix this. IMO this is the same bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81483

nfllab avatar Oct 25 '17 22:10 nfllab

Still seems to be present with gcc 8. However you can resolve by changing the format string to "%.2hhX" in the sprintf on line 659.

hunt732 avatar Jan 13 '21 15:01 hunt732