HomePhabricator

Fix bugs on 'unsigned char' platforms.
8c8e8c2e931bUnpublished

Unpublished Commit ยท Learn More

Repository Importing: This repository is still importing.

Description

Fix bugs on 'unsigned char' platforms.

In ISO C++, the signedness of 'char' is undefined. On some platforms (e.g.
ARM), 'char' is an unsigned type, but some of the code relies on 'char' being
signed (as it is on x86). This is indicated by compiler warnings like this:

bignum.h: In constructor 'CBigNum::CBigNum(char)':
bignum.h:81:59: warning: comparison is always true due to limited range of data type [-Wtype-limits]

util.cpp: In function 'bool IsHex(const string&)':
util.cpp:427:28: warning: comparison is always false due to limited range of data type [-Wtype-limits]

In particular, IsHex erroneously returned true regardless of the input
characters, as long as the length of the string was a positive multiple of 2.

Note: For testing, it's possible using GCC to force char to be unsigned by
adding the -funsigned-char parameter to xCXXFLAGS.

Details

Provenance
Dwayne C. Litzenberger <dlitz@dlitz.net>Authored on Apr 16 2012, 05:32
schancelPushed on Jan 5 2018, 21:58
schancelPushed on Jan 5 2018, 21:39
schancelPushed on Jan 5 2018, 21:17
Parents
rSTAGINGa6fa147c8d2d: Fix phexdigits[255] is undefined.
Branches
Unknown
Tags
Unknown

Event Timeline

Dwayne C. Litzenberger <dlitz@dlitz.net> committed rSTAGING8c8e8c2e931b: Fix bugs on 'unsigned char' platforms. (authored by Dwayne C. Litzenberger <dlitz@dlitz.net>).Apr 18 2012, 04:33