From a26267d16dcdc22a15722917a51dc50cdc8aaac0 Mon Sep 17 00:00:00 2001 From: Philipp A Hartmann Date: Sun, 15 Jul 2018 16:01:02 +0200 Subject: [PATCH] Fix -Wsign-conversion warnings/errors GCC 8 (incorrectly) warns about sign conversions in (constant) array size expressions: error: conversion to 'long unsigned int' from 'int' may change the sign of the result [-Werror=sign-conversion] char schemaBuffer_[128 * 1024]; Make these expressions unsigned by adding a 'u' suffix to the first operands. --- include/rapidjson/schema.h | 2 +- test/unittest/schematest.cpp | 2 +- test/unittest/simdtest.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/rapidjson/schema.h b/include/rapidjson/schema.h index dc0af78..fa0d696 100644 --- a/include/rapidjson/schema.h +++ b/include/rapidjson/schema.h @@ -464,7 +464,7 @@ public: enum_ = static_cast(allocator_->Malloc(sizeof(uint64_t) * v->Size())); for (ConstValueIterator itr = v->Begin(); itr != v->End(); ++itr) { typedef Hasher > EnumHasherType; - char buffer[256 + 24]; + char buffer[256u + 24]; MemoryPoolAllocator<> hasherAllocator(buffer, sizeof(buffer)); EnumHasherType h(&hasherAllocator, 256); itr->Accept(h); diff --git a/test/unittest/schematest.cpp b/test/unittest/schematest.cpp index 0c61a8a..3261069 100644 --- a/test/unittest/schematest.cpp +++ b/test/unittest/schematest.cpp @@ -1762,7 +1762,7 @@ private: typename DocumentType::AllocatorType documentAllocator_; typename SchemaDocumentType::AllocatorType schemaAllocator_; char documentBuffer_[16384]; - char schemaBuffer_[128 * 1024]; + char schemaBuffer_[128u * 1024]; }; TEST(SchemaValidator, TestSuite) { diff --git a/test/unittest/simdtest.cpp b/test/unittest/simdtest.cpp index 7b58cd0..c60c85b 100644 --- a/test/unittest/simdtest.cpp +++ b/test/unittest/simdtest.cpp @@ -109,8 +109,8 @@ struct ScanCopyUnescapedStringHandler : BaseReaderHandler, ScanCopyUnesca template void TestScanCopyUnescapedString() { - char buffer[1024 + 5 + 32]; - char backup[1024 + 5 + 32]; + char buffer[1024u + 5 + 32]; + char backup[1024u + 5 + 32]; // Test "ABCDABCD...\\" for (size_t offset = 0; offset < 32; offset++) {