Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 1 | From 7b05a74432f08ef34d0f8743dd6438ad012e3b5e Mon Sep 17 00:00:00 2001 |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 2 | From: Cody P Schafer <dev@codyps.com> |
| 3 | Date: Fri, 9 Sep 2016 15:50:26 -0400 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 4 | Subject: [PATCH] THRIFT-3831 in test/cpp explicitly use `signed char` |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 5 | |
| 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 Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 12 | |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 13 | --- |
| 14 | test/cpp/src/TestClient.cpp | 4 ++-- |
| 15 | 1 file changed, 2 insertions(+), 2 deletions(-) |
| 16 | |
| 17 | diff --git a/test/cpp/src/TestClient.cpp b/test/cpp/src/TestClient.cpp |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 18 | index 7c425a9..7145ebb 100644 |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 19 | --- a/test/cpp/src/TestClient.cpp |
| 20 | +++ b/test/cpp/src/TestClient.cpp |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 21 | @@ -381,7 +381,7 @@ int main(int argc, char** argv) { |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 22 | * 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 Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 30 | @@ -402,7 +402,7 @@ int main(int argc, char** argv) { |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 31 | 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()); |