-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Open
Description
Description
When compiling tutorial.cpp, the build fails due to a const assignment error in rapidjson/document.h
Reproduce
wget https://github.com/Tencent/rapidjson/archive/refs/tags/v1.1.0.tar.gz
tar -xf v1.1.0.tar.gz
mv rapidjson-1.1.0/include/rapidjson .
mv rapidjson-1.1.0/example/tutorial/tutorial.cpp .
zig c++ tutorial.cpp --std=c++17
Error
Click to expand!
In file included from tutorial.cpp:4:
./rapidjson/document.h:319:82: error: cannot assign to non-static data member 'length' with const-qualified type 'const SizeType' (aka 'const unsigned int')
319 | GenericStringRef& operator=(const GenericStringRef& rhs) { s = rhs.s; length = rhs.length; }
| ~~~~~~ ^
./rapidjson/document.h:325:20: note: non-static data member 'length' declared const here
325 | const SizeType length; //!< length of the string (excluding the trailing NULL terminator)
| ~~~~~~~~~~~~~~~^~~~~~
./rapidjson/document.h:102:19: warning: 'iterator<std::random_access_iterator_tag, rapidjson::GenericMember<rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator<>>>' is deprecated [-Wdeprecated-declarations]
102 | : public std::iterator<std::random_access_iterator_tag
| ^
./rapidjson/document.h:548:22: note: in instantiation of template class 'rapidjson::GenericMemberIterator<false, rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator<>>' requested here
548 | typedef typename GenericMemberIterator<false,Encoding,Allocator>::Iterator MemberIterator; //!< Member iterator for iterating in object.
| ^
./rapidjson/document.h:2024:32: note: in instantiation of template class 'rapidjson::GenericValue<rapidjson::UTF8<>>' requested here
2024 | class GenericDocument : public GenericValue<Encoding, Allocator> {
| ^
tutorial.cpp:18:14: note: in instantiation of template class 'rapidjson::GenericDocument<rapidjson::UTF8<>>' requested here
18 | Document document; // Default template parameter uses UTF8 and MemoryPoolAllocator.
| ^
zig-x86_64-linux-0.15.2/lib/libcxx/include/__iterator/iterator.h:23:29: note: 'iterator<std::random_access_iterator_tag, rapidjson::GenericMember<rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator<>>>' has been explicitly marked deprecated here
23 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 iterator {
| ^
zig-x86_64-linux-0.15.2/lib/libcxx/include/__config:725:41: note: expanded from macro '_LIBCPP_DEPRECATED_IN_CXX17'
725 | # define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED
| ^
zig-x86_64-linux-0.15.2/lib/libcxx/include/__config:698:49: note: expanded from macro '_LIBCPP_DEPRECATED'
698 | # define _LIBCPP_DEPRECATED __attribute__((__deprecated__))
| ^
In file included from tutorial.cpp:4:
./rapidjson/document.h:110:18: warning: 'iterator<std::random_access_iterator_tag, rapidjson::GenericMember<rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator<>>>' is deprecated [-Wdeprecated-declarations]
110 | typedef std::iterator<std::random_access_iterator_tag,ValueType> BaseType;
| ^
zig-x86_64-linux-0.15.2/lib/libcxx/include/__iterator/iterator.h:23:29: note: 'iterator<std::random_access_iterator_tag, rapidjson::GenericMember<rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator<>>>' has been explicitly marked deprecated here
23 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 iterator {
| ^
zig-x86_64-linux-0.15.2/lib/libcxx/include/__config:725:41: note: expanded from macro '_LIBCPP_DEPRECATED_IN_CXX17'
725 | # define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED
| ^
zig-x86_64-linux-0.15.2/lib/libcxx/include/__config:698:49: note: expanded from macro '_LIBCPP_DEPRECATED'
698 | # define _LIBCPP_DEPRECATED __attribute__((__deprecated__))
| ^
In file included from tutorial.cpp:4:
./rapidjson/document.h:102:19: warning: 'iterator<std::random_access_iterator_tag, const rapidjson::GenericMember<rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator<>>>' is deprecated [-Wdeprecated-declarations]
102 | : public std::iterator<std::random_access_iterator_tag
| ^
./rapidjson/document.h:549:22: note: in instantiation of template class 'rapidjson::GenericMemberIterator<true, rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator<>>' requested here
549 | typedef typename GenericMemberIterator<true,Encoding,Allocator>::Iterator ConstMemberIterator; //!< Constant member iterator for iterating in object.
| ^
./rapidjson/document.h:2024:32: note: in instantiation of template class 'rapidjson::GenericValue<rapidjson::UTF8<>>' requested here
2024 | class GenericDocument : public GenericValue<Encoding, Allocator> {
| ^
tutorial.cpp:18:14: note: in instantiation of template class 'rapidjson::GenericDocument<rapidjson::UTF8<>>' requested here
18 | Document document; // Default template parameter uses UTF8 and MemoryPoolAllocator.
| ^
zig-x86_64-linux-0.15.2/lib/libcxx/include/__iterator/iterator.h:23:29: note: 'iterator<std::random_access_iterator_tag, const rapidjson::GenericMember<rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator<>>>' has been explicitly marked deprecated here
23 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 iterator {
| ^
zig-x86_64-linux-0.15.2/lib/libcxx/include/__config:725:41: note: expanded from macro '_LIBCPP_DEPRECATED_IN_CXX17'
725 | # define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED
| ^
zig-x86_64-linux-0.15.2/lib/libcxx/include/__config:698:49: note: expanded from macro '_LIBCPP_DEPRECATED'
698 | # define _LIBCPP_DEPRECATED __attribute__((__deprecated__))
| ^
In file included from tutorial.cpp:4:
./rapidjson/document.h:110:18: warning: 'iterator<std::random_access_iterator_tag, const rapidjson::GenericMember<rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator<>>>' is deprecated [-Wdeprecated-declarations]
110 | typedef std::iterator<std::random_access_iterator_tag,ValueType> BaseType;
| ^
zig-x86_64-linux-0.15.2/lib/libcxx/include/__iterator/iterator.h:23:29: note: 'iterator<std::random_access_iterator_tag, const rapidjson::GenericMember<rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator<>>>' has been explicitly marked deprecated here
23 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 iterator {
| ^
zig-x86_64-linux-0.15.2/lib/libcxx/include/__config:725:41: note: expanded from macro '_LIBCPP_DEPRECATED_IN_CXX17'
725 | # define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED
| ^
zig-x86_64-linux-0.15.2/lib/libcxx/include/__config:698:49: note: expanded from macro '_LIBCPP_DEPRECATED'
698 | # define _LIBCPP_DEPRECATED __attribute__((__deprecated__))
| ^
In file included from tutorial.cpp:4:
./rapidjson/document.h:1952:25: warning: first argument in call to 'memcpy' is a pointer to non-trivially copyable type 'Member' (aka 'GenericMember<rapidjson::UTF8<char>, rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>') [-Wnontrivial-memcall]
1952 | std::memcpy(m, members, count * sizeof(Member));
| ^
./rapidjson/document.h:2363:43: note: in instantiation of member function 'rapidjson::GenericValue<rapidjson::UTF8<>>::SetObjectRaw' requested here
2363 | stack_.template Top<ValueType>()->SetObjectRaw(members, memberCount, GetAllocator());
| ^
./rapidjson/reader.h:1736:31: note: in instantiation of member function 'rapidjson::GenericDocument<rapidjson::UTF8<>>::EndObject' requested here
1736 | bool hr = handler.EndObject(c);
| ^
./rapidjson/reader.h:1832:39: note: in instantiation of function template specialization 'rapidjson::GenericReader<rapidjson::UTF8<>, rapidjson::UTF8<>>::Transit<1U, rapidjson::GenericInsituStringStream<rapidjson::UTF8<>>, rapidjson::GenericDocument<rapidjson::UTF8<>>>' requested here
1832 | IterativeParsingState d = Transit<parseFlags>(state, t, n, is, handler);
| ^
./rapidjson/reader.h:487:20: note: in instantiation of function template specialization 'rapidjson::GenericReader<rapidjson::UTF8<>, rapidjson::UTF8<>>::IterativeParse<1U, rapidjson::GenericInsituStringStream<rapidjson::UTF8<>>, rapidjson::GenericDocument<rapidjson::UTF8<>>>' requested here
487 | return IterativeParse<parseFlags>(is, handler);
| ^
./rapidjson/document.h:2159:40: note: in instantiation of function template specialization 'rapidjson::GenericReader<rapidjson::UTF8<>, rapidjson::UTF8<>>::Parse<1U, rapidjson::GenericInsituStringStream<rapidjson::UTF8<>>, rapidjson::GenericDocument<rapidjson::UTF8<>>>' requested here
2159 | parseResult_ = reader.template Parse<parseFlags>(is, *this);
| ^
./rapidjson/document.h:2175:16: note: in instantiation of function template specialization 'rapidjson::GenericDocument<rapidjson::UTF8<>>::ParseStream<1U, rapidjson::UTF8<>, rapidjson::GenericInsituStringStream<rapidjson::UTF8<>>>' requested here
2175 | return ParseStream<parseFlags, Encoding, InputStream>(is);
| ^
./rapidjson/document.h:2200:16: note: in instantiation of function template specialization 'rapidjson::GenericDocument<rapidjson::UTF8<>>::ParseStream<1U, rapidjson::GenericInsituStringStream<rapidjson::UTF8<>>>' requested here
2200 | return ParseStream<parseFlags | kParseInsituFlag>(s);
| ^
./rapidjson/document.h:2208:16: note: in instantiation of function template specialization 'rapidjson::GenericDocument<rapidjson::UTF8<>>::ParseInsitu<0U>' requested here
2208 | return ParseInsitu<kParseDefaultFlags>(str);
| ^
tutorial.cpp:28:18: note: in instantiation of member function 'rapidjson::GenericDocument<rapidjson::UTF8<>>::ParseInsitu' requested here
28 | if (document.ParseInsitu(buffer).HasParseError())
| ^
./rapidjson/document.h:1952:25: note: explicitly cast the pointer to silence this warning
1952 | std::memcpy(m, members, count * sizeof(Member));
| ^
| (void*)
./rapidjson/document.h:1939:25: warning: first argument in call to 'memcpy' is a pointer to non-trivially copyable type 'GenericValue<UTF8<>>' [-Wnontrivial-memcall]
1939 | std::memcpy(e, values, count * sizeof(GenericValue));
| ^
./rapidjson/document.h:2371:43: note: in instantiation of member function 'rapidjson::GenericValue<rapidjson::UTF8<>>::SetArrayRaw' requested here
2371 | stack_.template Top<ValueType>()->SetArrayRaw(elements, elementCount, GetAllocator());
| ^
./rapidjson/reader.h:1766:31: note: in instantiation of member function 'rapidjson::GenericDocument<rapidjson::UTF8<>>::EndArray' requested here
1766 | bool hr = handler.EndArray(c);
| ^
./rapidjson/reader.h:1832:39: note: in instantiation of function template specialization 'rapidjson::GenericReader<rapidjson::UTF8<>, rapidjson::UTF8<>>::Transit<1U, rapidjson::GenericInsituStringStream<rapidjson::UTF8<>>, rapidjson::GenericDocument<rapidjson::UTF8<>>>' requested here
1832 | IterativeParsingState d = Transit<parseFlags>(state, t, n, is, handler);
| ^
./rapidjson/reader.h:487:20: note: in instantiation of function template specialization 'rapidjson::GenericReader<rapidjson::UTF8<>, rapidjson::UTF8<>>::IterativeParse<1U, rapidjson::GenericInsituStringStream<rapidjson::UTF8<>>, rapidjson::GenericDocument<rapidjson::UTF8<>>>' requested here
487 | return IterativeParse<parseFlags>(is, handler);
| ^
./rapidjson/document.h:2159:40: note: in instantiation of function template specialization 'rapidjson::GenericReader<rapidjson::UTF8<>, rapidjson::UTF8<>>::Parse<1U, rapidjson::GenericInsituStringStream<rapidjson::UTF8<>>, rapidjson::GenericDocument<rapidjson::UTF8<>>>' requested here
2159 | parseResult_ = reader.template Parse<parseFlags>(is, *this);
| ^
./rapidjson/document.h:2175:16: note: in instantiation of function template specialization 'rapidjson::GenericDocument<rapidjson::UTF8<>>::ParseStream<1U, rapidjson::UTF8<>, rapidjson::GenericInsituStringStream<rapidjson::UTF8<>>>' requested here
2175 | return ParseStream<parseFlags, Encoding, InputStream>(is);
| ^
./rapidjson/document.h:2200:16: note: in instantiation of function template specialization 'rapidjson::GenericDocument<rapidjson::UTF8<>>::ParseStream<1U, rapidjson::GenericInsituStringStream<rapidjson::UTF8<>>>' requested here
2200 | return ParseStream<parseFlags | kParseInsituFlag>(s);
| ^
./rapidjson/document.h:2208:16: note: in instantiation of function template specialization 'rapidjson::GenericDocument<rapidjson::UTF8<>>::ParseInsitu<0U>' requested here
2208 | return ParseInsitu<kParseDefaultFlags>(str);
| ^
tutorial.cpp:28:18: note: in instantiation of member function 'rapidjson::GenericDocument<rapidjson::UTF8<>>::ParseInsitu' requested here
28 | if (document.ParseInsitu(buffer).HasParseError())
| ^
./rapidjson/document.h:1939:25: note: explicitly cast the pointer to silence this warning
1939 | std::memcpy(e, values, count * sizeof(GenericValue));
| ^
| (void*)
6 warnings and 1 error generated.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels