blob: 37715c281b426719ff040d28fc8afa275893907d [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001From 7b05a74432f08ef34d0f8743dd6438ad012e3b5e Mon Sep 17 00:00:00 2001
Patrick Williamsddad1a12017-02-23 20:36:32 -06002From: Cody P Schafer <dev@codyps.com>
3Date: Fri, 9 Sep 2016 15:50:26 -0400
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08004Subject: [PATCH] THRIFT-3831 in test/cpp explicitly use `signed char`
Patrick Williamsddad1a12017-02-23 20:36:32 -06005
6`char`'s signed-ness is implimentation dependent, and in the case where
7`char` was not signed, we previously recieved errors like
8
9 thrift/0.9.3-r0/git/test/cpp/src/TestClient.cpp:404:15: error: narrowing conversion of '-127' from 'int' to 'char' inside { } [-Wnarrowing]
10
11(This example from gcc-6 on arm)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080012
Patrick Williamsddad1a12017-02-23 20:36:32 -060013---
14 test/cpp/src/TestClient.cpp | 4 ++--
15 1 file changed, 2 insertions(+), 2 deletions(-)
16
17diff --git a/test/cpp/src/TestClient.cpp b/test/cpp/src/TestClient.cpp
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080018index 7c425a9..7145ebb 100644
Patrick Williamsddad1a12017-02-23 20:36:32 -060019--- a/test/cpp/src/TestClient.cpp
20+++ b/test/cpp/src/TestClient.cpp
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080021@@ -381,7 +381,7 @@ int main(int argc, char** argv) {
Patrick Williamsddad1a12017-02-23 20:36:32 -060022 * BINARY TEST
23 */
24 printf("testBinary([-128..127]) = {");
25- const char bin_data[256]
26+ const signed char bin_data[256]
27 = {-128, -127, -126, -125, -124, -123, -122, -121, -120, -119, -118, -117, -116, -115, -114,
28 -113, -112, -111, -110, -109, -108, -107, -106, -105, -104, -103, -102, -101, -100, -99,
29 -98, -97, -96, -95, -94, -93, -92, -91, -90, -89, -88, -87, -86, -85, -84,
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080030@@ -402,7 +402,7 @@ int main(int argc, char** argv) {
Patrick Williamsddad1a12017-02-23 20:36:32 -060031 127};
32 try {
33 string bin_result;
34- testClient.testBinary(bin_result, string(bin_data, 256));
35+ testClient.testBinary(bin_result, string(reinterpret_cast<const char *>(bin_data), 256));
36 if (bin_result.size() != 256) {
37 printf("}\n*** FAILED ***\n");
38 printf("invalid length: %lu\n", bin_result.size());