Skip to content

Commit a5705f2

Browse files
authored
Fix build for unsigned-char (#249)
* Fix build for unsigned-char * Fix typo
1 parent a834f6f commit a5705f2

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

.circleci/config.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ jobs:
4444
- run: ./ci/install_bazel.sh
4545
- run: ./ci/do_ci.sh bazel.test
4646

47+
# Verify that we can work on architectures that default to use an unsigned char
48+
# See https://github.com/lightstep/lightstep-tracer-cpp/issues/246
49+
# https://github.com/lightstep/lightstep-tracer-cpp/pull/245
50+
unsigned_char_test:
51+
resource_class: xlarge
52+
docker:
53+
- image: ubuntu:18.04
54+
steps:
55+
- checkout
56+
- run: ./ci/setup_build_environment.sh
57+
- run: ./ci/install_bazel.sh
58+
- run: ./ci/do_ci.sh bazel.unsigned_char.test
59+
4760
asan:
4861
resource_class: xlarge
4962
docker:
@@ -294,6 +307,7 @@ workflows:
294307
- cmake_no_grpc
295308
- cmake_with_grpc
296309
- test
310+
- unsigned_char_test
297311
- asan
298312
- tsan
299313
- windows

ci/do_ci.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ elif [[ "$1" == "bazel.test" ]]; then
7979
bazel build -c dbg $BAZEL_OPTIONS -- //... -//benchmark/...
8080
bazel test -c dbg $BAZEL_TEST_OPTIONS //...
8181
exit 0
82+
elif [[ "$1" == "bazel.unsigned_char.test" ]]; then
83+
bazel build -c dbg --copt -funsigned-char $BAZEL_OPTIONS -- //... -//benchmark/...
84+
bazel test -c dbg --copt -funsigned-char $BAZEL_TEST_OPTIONS //...
85+
exit 0
8286
elif [[ "$1" == "bazel.asan" ]]; then
8387
setup_clang_toolchain
8488
bazel test -c dbg \

src/common/utility.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ timeval ToTimeval(std::chrono::microseconds microseconds) {
5151
static void WriteEscapedString(std::ostringstream& writer,
5252
opentracing::string_view s) {
5353
writer << '"';
54-
for (char c : s) {
54+
for (auto c_prime : s) {
55+
auto c = static_cast<signed char>(c_prime);
5556
switch (c) {
5657
case '"':
5758
writer << R"(\")";
@@ -72,7 +73,8 @@ static void WriteEscapedString(std::ostringstream& writer,
7273
writer << R"(\t)";
7374
break;
7475
default:
75-
if ('\x00' <= c && c <= '\x1f') {
76+
if (static_cast<signed char>('\x00') <= c &&
77+
c <= static_cast<signed char>('\x1f')) {
7678
writer << R"(\u)";
7779
writer << std::hex << std::setw(4) << std::setfill('0')
7880
<< static_cast<int>(c);

0 commit comments

Comments
 (0)