diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2019-07-30 16:58:16 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2019-07-30 16:58:24 +0200 |
commit | 74f1a27f2f45af7dafcc34df766cf76d29c7c6ed (patch) | |
tree | dc2bf76bf5350aa9c3de9b0eeb4fc24f53157d85 /.travis.yml | |
parent | bd35ec36f5d6b4e65e886eaf24f8985d86f85753 (diff) | |
parent | 0c78e49be3a258695b7f363f2d5b1cfdb93f9522 (diff) |
Merge #15134: tests: Switch one of the Travis jobs to an unsigned char environment (-funsigned-char)
0c78e49be3a258695b7f363f2d5b1cfdb93f9522 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 0c78e49be3a258695b7f363f2d5b1cfdb93f9522
Tree-SHA512: ba04590415c0bb9a0bbd348623e57068f75274f53da7247d5c5ecad82e365a5b45893a4a491d318e82a8feb6a25f019d46e01990afb33162e2c9740d33a343d7
Diffstat (limited to '.travis.yml')
-rw-r--r-- | .travis.yml | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/.travis.yml b/.travis.yml index add59d49e0..422e9149f4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -130,14 +130,14 @@ jobs: CONFIG_SHELL="/bin/dash" - stage: test - name: 'x86_64 Linux [GOAL: install] [bionic] [uses qt5 dev package instead of depends Qt to speed up build and avoid timeout]' + name: 'x86_64 Linux [GOAL: install] [bionic] [uses qt5 dev package instead of depends Qt to speed up build and avoid timeout] [unsigned char]' env: >- HOST=x86_64-unknown-linux-gnu PACKAGES="python3-zmq qtbase5-dev qttools5-dev-tools protobuf-compiler libdbus-1-dev libharfbuzz-dev libprotobuf-dev" DEP_OPTS="NO_QT=1 NO_UPNP=1 DEBUG=1 ALLOW_HOST_PACKAGES=1" TEST_RUNNER_EXTRA="--coverage --extended --exclude feature_dbcrash" # Run extended tests so that coverage does not fail, but exclude the very slow dbcrash GOAL="install" - BITCOIN_CONFIG="--enable-zmq --with-gui=qt5 --enable-glibc-back-compat --enable-reduce-exports --enable-debug CXXFLAGS=\"-g0 -O2\"" + 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\"" - stage: test name: 'x86_64 Linux [GOAL: install] [trusty] [no functional tests, no depends, only system libs]' |