rapidjson
rapidjson copied to clipboard
Compilation errors with GCC 11.2.0
Trying to compile the latest commit (see 8261c1ddf43f10de00fd8c9a67811d1486b2c784) with GCC 11.2.0 I have the following errors:
Building CXX object test/unittest/CMakeFiles/unittest.dir/itoatest.cpp.o
cd /usr/src/tmp/rapidjson-8261c1ddf43f10de00fd8c9a67811d1486b2c784/build/test/unittest && ccache /usr/bin/c++ -I/usr/src/tmp/rapidjson-8261c1ddf43f10de00fd8c9a67811d1486b2c784/include -isystem /usr/src/googletest/googletest/include -isystem /usr/src/googletest/googletest -O3 -march=i586 -mtune=i686 -march=native -Wall -Wextra -Werror -DRAPIDJSON_HAS_STDSTRING=1 -O3 -DNDEBUG -Weffc++ -Wswitch-default -Wfloat-equal -Wconversion -Wsign-conversion -std=gnu++11 -MD -MT test/unittest/CMakeFiles/unittest.dir/itoatest.cpp.o -MF CMakeFiles/unittest.dir/itoatest.cpp.o.d -o CMakeFiles/unittest.dir/itoatest.cpp.o -c /usr/src/tmp/rapidjson-8261c1ddf43f10de00fd8c9a67811d1486b2c784/test/unittest/itoatest.cpp
In function ‘void u32toa_naive(uint32_t, char*)’,
inlined from ‘void VerifyValue(T, void (*)(T, char*), char* (*)(T, char*)) [with T = unsigned int]’ at /usr/src/tmp/rapidjson-8261c1ddf43f10de00fd8c9a67811d1486b2c784/test/unittest/itoatest.cpp:62:6:
/usr/src/tmp/rapidjson-8261c1ddf43f10de00fd8c9a67811d1486b2c784/test/unittest/itoatest.cpp:103:19: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
103 | *buffer++ = *--p;
| ~~~~~~~~~~^~~~~~
/usr/src/tmp/rapidjson-8261c1ddf43f10de00fd8c9a67811d1486b2c784/test/unittest/itoatest.cpp:103:19: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
/usr/src/tmp/rapidjson-8261c1ddf43f10de00fd8c9a67811d1486b2c784/test/unittest/itoatest.cpp:103:19: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
/usr/src/tmp/rapidjson-8261c1ddf43f10de00fd8c9a67811d1486b2c784/test/unittest/itoatest.cpp:103:19: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
In function ‘void u32toa_naive(uint32_t, char*)’,
inlined from ‘void i32toa_naive(int32_t, char*)’ at /usr/src/tmp/rapidjson-8261c1ddf43f10de00fd8c9a67811d1486b2c784/test/unittest/itoatest.cpp:115:17,
inlined from ‘void VerifyValue(T, void (*)(T, char*), char* (*)(T, char*)) [with T = int]’ at /usr/src/tmp/rapidjson-8261c1ddf43f10de00fd8c9a67811d1486b2c784/test/unittest/itoatest.cpp:62:6:
/usr/src/tmp/rapidjson-8261c1ddf43f10de00fd8c9a67811d1486b2c784/test/unittest/itoatest.cpp:103:19: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
103 | *buffer++ = *--p;
| ~~~~~~~~~~^~~~~~
/usr/src/tmp/rapidjson-8261c1ddf43f10de00fd8c9a67811d1486b2c784/test/unittest/itoatest.cpp:103:19: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
/usr/src/tmp/rapidjson-8261c1ddf43f10de00fd8c9a67811d1486b2c784/test/unittest/itoatest.cpp:103:19: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
cc1plus: all warnings being treated as errors
make[2]: *** [test/unittest/CMakeFiles/unittest.dir/build.make:219: test/unittest/CMakeFiles/unittest.dir/itoatest.cpp.o] Error 1
And
Building CXX object test/unittest/CMakeFiles/unittest.dir/pointertest.cpp.o
cd /usr/src/tmp/rapidjson-8261c1ddf43f10de00fd8c9a67811d1486b2c784/build/test/unittest && ccache /usr/bin/c++ -I/usr/src/tmp/rapidjson-8261c1ddf43f10de00fd8c9a67811d1486b2c784/include -isystem /usr/src/googletest/googletest/include -isystem /usr/src/googletest/googletest -O3 -march=i586 -mtune=i686 -march=native -Wall -Wextra -Werror -DRAPIDJSON_HAS_STDSTRING=1 -O3 -DNDEBUG -Weffc++ -Wswitch-default -Wfloat-equal -Wconversion -Wsign-conversion -std=gnu++11 -MD -MT test/unittest/CMakeFiles/unittest.dir/pointertest.cpp.o -MF CMakeFiles/unittest.dir/pointertest.cpp.o.d -o CMakeFiles/unittest.dir/pointertest.cpp.o -c /usr/src/tmp/rapidjson-8261c1ddf43f10de00fd8c9a67811d1486b2c784/test/unittest/pointertest.cpp
In file included from /usr/src/tmp/rapidjson-8261c1ddf43f10de00fd8c9a67811d1486b2c784/test/unittest/pointertest.cpp:16:
In member function ‘rapidjson::GenericPointer<ValueType, Allocator> rapidjson::GenericPointer<ValueType, Allocator>::Append(const rapidjson::GenericPointer<ValueType, Allocator>::Token&, Allocator*) const [with ValueType = rapidjson::GenericValue<rapidjson::UTF8<> >; Allocator = rapidjson::CrtAllocator]’,
inlined from ‘rapidjson::GenericPointer<ValueType, Allocator> rapidjson::GenericPointer<ValueType, Allocator>::Append(const Ch*, rapidjson::SizeType, Allocator*) const [with ValueType = rapidjson::GenericValue<rapidjson::UTF8<> >; Allocator = rapidjson::CrtAllocator]’ at /usr/src/tmp/rapidjson-8261c1ddf43f10de00fd8c9a67811d1486b2c784/include/rapidjson/pointer.h:267:39,
inlined from ‘rapidjson::GenericPointer<ValueType, Allocator> rapidjson::GenericPointer<ValueType, Allocator>::Append(const std::__cxx11::basic_string<typename ValueType::Ch>&, Allocator*) const [with ValueType = rapidjson::GenericValue<rapidjson::UTF8<> >; Allocator = rapidjson::CrtAllocator]’ at /usr/src/tmp/rapidjson-8261c1ddf43f10de00fd8c9a67811d1486b2c784/include/rapidjson/pointer.h:290:82,
inlined from ‘virtual void Pointer_Append_Test::TestBody()’ at /usr/src/tmp/rapidjson-8261c1ddf43f10de00fd8c9a67811d1486b2c784/test/unittest/pointertest.cpp:591:48:
/usr/src/tmp/rapidjson-8261c1ddf43f10de00fd8c9a67811d1486b2c784/include/rapidjson/pointer.h:251:20: error: ‘void* memcpy(void*, const void*, size_t)’ specified bound 4294967284 exceeds maximum object size 2147483647 [-Werror=stringop-overflow=]
251 | std::memcpy(p, token.name, (token.length + 1) * sizeof(Ch));
| ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [test/unittest/CMakeFiles/unittest.dir/build.make:275: test/unittest/CMakeFiles/unittest.dir/pointertest.cpp.o] Error 1
The errors are reproducible also with commit 418331e99f859f00bdc8306f69eba67e8693c55e (from 2020-01-17 i.e. more than two years ago).
Hi what was the solution to this - do I just need a newer g++?
@LAHumphreys I found no solution, so I reverted to a version before these modifications were introduced in order to compile with GCC 11.2. Apparently repository owners do not care about this issue as it hasn't been answered in more than a year...