Skip to content

Commit a26267d

Browse files
committed
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.
1 parent fa5963a commit a26267d

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

include/rapidjson/schema.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ class Schema {
464464
enum_ = static_cast<uint64_t*>(allocator_->Malloc(sizeof(uint64_t) * v->Size()));
465465
for (ConstValueIterator itr = v->Begin(); itr != v->End(); ++itr) {
466466
typedef Hasher<EncodingType, MemoryPoolAllocator<> > EnumHasherType;
467-
char buffer[256 + 24];
467+
char buffer[256u + 24];
468468
MemoryPoolAllocator<> hasherAllocator(buffer, sizeof(buffer));
469469
EnumHasherType h(&hasherAllocator, 256);
470470
itr->Accept(h);

test/unittest/schematest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1762,7 +1762,7 @@ class RemoteSchemaDocumentProvider : public IGenericRemoteSchemaDocumentProvider
17621762
typename DocumentType::AllocatorType documentAllocator_;
17631763
typename SchemaDocumentType::AllocatorType schemaAllocator_;
17641764
char documentBuffer_[16384];
1765-
char schemaBuffer_[128 * 1024];
1765+
char schemaBuffer_[128u * 1024];
17661766
};
17671767

17681768
TEST(SchemaValidator, TestSuite) {

test/unittest/simdtest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ struct ScanCopyUnescapedStringHandler : BaseReaderHandler<UTF8<>, ScanCopyUnesca
109109

110110
template <unsigned parseFlags, typename StreamType>
111111
void TestScanCopyUnescapedString() {
112-
char buffer[1024 + 5 + 32];
113-
char backup[1024 + 5 + 32];
112+
char buffer[1024u + 5 + 32];
113+
char backup[1024u + 5 + 32];
114114

115115
// Test "ABCDABCD...\\"
116116
for (size_t offset = 0; offset < 32; offset++) {

0 commit comments

Comments
 (0)