Skip to content

Commit 74f1a27

Browse files
committed
Merge #15134: tests: Switch one of the Travis jobs to an unsigned char environment (-funsigned-char)
0c78e49 tests: Switch one of the Travis jobs to an unsigned char environment (-funsigned-char) (practicalswift) Pull request description: Switch one of the Travis jobs to an unsigned char environment (`-funsigned-char`). This will help us catch errors due to code written under the assumption that `char` has the same value range as `signed char`. The signedness of `char` is implementation-defined. Example: ``` $ uname -a Linux […] x86_64 x86_64 x86_64 GNU/Linux $ cat foo.cpp #include <iostream> int main() { char c; std::cin >> c; int i = (unsigned char)c; std::cout << i << "\n"; } $ clang++ -o foo foo.cpp $ echo -e "\xff" | ./foo 255 $ clang++ -fsigned-char -o foo foo.cpp $ echo -e "\xff" | ./foo 255 $ clang++ -funsigned-char -o foo foo.cpp $ echo -e "\xff" | ./foo 255 $ cat bar.cpp #include <iostream> int main() { char c; std::cin >> c; int i = c; std::cout << i << "\n"; } $ clang++ -o bar bar.cpp $ echo -e "\xff" | ./bar -1 $ clang++ -fsigned-char -o bar bar.cpp $ echo -e "\xff" | ./bar -1 $ clang++ -funsigned-char -o bar bar.cpp $ echo -e "\xff" | ./bar 255 ``` `gcc` chars: * signed: alpha, hppa, ia64, m68k, mips, sh, sparc, x86 * unsigned: arm, powerpc, s390 About `-funsigned-char`: > Let the type "char" be unsigned, like "unsigned char". > > Each kind of machine has a default for what "char" should be. It is either like "unsigned char" by default or like "signed char" by default. > > Ideally, a portable program should always use "signed char" or "unsigned char" when it depends on the signedness of an object. But many programs have been written to use plain "char" and expect it to be signed, or expect it to be unsigned, depending on the machines they were written for. > > This option, and its inverse, let you make such a program work with the opposite default. The type "char" is always a distinct type from each of "signed char" or "unsigned char", even though its behavior is always just like one of those two. ACKs for top commit: laanwj: ACK 0c78e49 Tree-SHA512: ba04590415c0bb9a0bbd348623e57068f75274f53da7247d5c5ecad82e365a5b45893a4a491d318e82a8feb6a25f019d46e01990afb33162e2c9740d33a343d7
2 parents bd35ec3 + 0c78e49 commit 74f1a27

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,14 @@ jobs:
130130
CONFIG_SHELL="/bin/dash"
131131
132132
- stage: test
133-
name: 'x86_64 Linux [GOAL: install] [bionic] [uses qt5 dev package instead of depends Qt to speed up build and avoid timeout]'
133+
name: 'x86_64 Linux [GOAL: install] [bionic] [uses qt5 dev package instead of depends Qt to speed up build and avoid timeout] [unsigned char]'
134134
env: >-
135135
HOST=x86_64-unknown-linux-gnu
136136
PACKAGES="python3-zmq qtbase5-dev qttools5-dev-tools protobuf-compiler libdbus-1-dev libharfbuzz-dev libprotobuf-dev"
137137
DEP_OPTS="NO_QT=1 NO_UPNP=1 DEBUG=1 ALLOW_HOST_PACKAGES=1"
138138
TEST_RUNNER_EXTRA="--coverage --extended --exclude feature_dbcrash" # Run extended tests so that coverage does not fail, but exclude the very slow dbcrash
139139
GOAL="install"
140-
BITCOIN_CONFIG="--enable-zmq --with-gui=qt5 --enable-glibc-back-compat --enable-reduce-exports --enable-debug CXXFLAGS=\"-g0 -O2\""
140+
BITCOIN_CONFIG="--enable-zmq --with-gui=qt5 --enable-glibc-back-compat --enable-reduce-exports --enable-debug CFLAGS=\"-g0 -O2 -funsigned-char\" CXXFLAGS=\"-g0 -O2 -funsigned-char\""
141141
142142
- stage: test
143143
name: 'x86_64 Linux [GOAL: install] [trusty] [no functional tests, no depends, only system libs]'

0 commit comments

Comments
 (0)