Issue #330 is a bug in proto3 behavior and the test case handling it
needs a 'syntax = "proto3";' line in its .proto file, which is not
supported by the protobuf 2 implementation.
Since we still support building against protobuf 2, this commit
conditionalizes the Issue #330 test case so that it is only built when
protobuf-c is being built against protobuf 3.
* allow compilation with -pedantic (thanks @Bun)
Can be reproduced with the following command:
$ make CFLAGS=-pedantic protobuf-c/protobuf-c.o
* put el-size on a separate line
The scan_length_prefixed_data() function returns the number of bytes
taken up by a varint length delimiter, plus the actual value of that
delimiter. Since it returns a uint32_t, a delimiter of 2^32 - 1 (or
close to that) could cause the return value to overflow and result in an
incorrect value.
At first I tried to fix it by making scan_length_prefixed_data() use a
size_t for its result, but I realized this would have no effect on
32-bit systems. To fix the problem for 32-bit, I changed the function to
return early if the length is 2 GiB or more (protobuf messages are not
allowed to be that large). I kept the size_t change anyway, since the
result will ultimately be stored in a size_t (ScannedMember.len) and we
might as well stay consistent with that.
Signed-off-by: Adam Cozzette <acozzette@google.com>
google::protobuf::Message::Reflection has been removed in newer versions
of protobuf. The replacement is google::protobuf::Reflection.
protobuf in commit 779f61c6a3ce02a119e28e802f229e61b69b9046 ("Integrate
recent changes from google3.", from August 2008) changed the following
in message.h:
@@ -336,7 +337,8 @@ class LIBPROTOBUF_EXPORT Message {
// Introspection ---------------------------------------------------
- class Reflection; // Defined below.
+ // Typedef for backwards-compatibility.
+ typedef google::protobuf::Reflection Reflection;
The "typedef for backwards-compatibility" apparently lasted ten years
until protobuf commit 6bbe197e9c1b6fc38cbdc45e3bf83fa7ced792a3
("Down-integrate from google3.", from August 2018) which finally removed
the typedef:
@@ -327,8 +344,6 @@ class LIBPROTOBUF_EXPORT Message : public MessageLite {
// Introspection ---------------------------------------------------
- // Typedef for backwards-compatibility.
- typedef google::protobuf::Reflection Reflection;
This commit updates the only use of this typedef (in the test suite) to
directly refer to the replacement, google::protobuf::Reflection. This
fixes the build failure in the test suite.
This reverts commit 0585e053a8723fbdea4deefe17b6a6512274cde5.
Now that we autodetect any needed flags to enable C++11 support with the
AX_CXX_COMPILE_STDCXX macro, we no longer need to force this in
.travis.yml.
This commit enables use of the AX_CXX_COMPILE_STDCXX macro from the
autoconf-archive (added in the previous commit), which automatically
adds needed flags to the CXX variable to enable C++11 support. This only
works and is only required on compilers that are both new enough to have
C++11 support and old enough to not enable it by default.
We call it with "noext" as the second argument (so that we get the "std"
C++11 variant on GCC) and "mandatory" as the third argument, since we
now rely on C++11 features as of 83c59e705f461cc08e5844d62514dff27c33a74f.
Note that this macro is only called when we are building the compiler
(i.e., without --disable-protoc) so that the library can still be built
on ancient C compilers.
Upstream protobuf removed scoped_ptr.h, which provided the scoped_ptr
that we depended on, in commit 67952fab2c766ac5eacc15bb78e5af4039a3d398
(67952fab2c).
This commit converts uses of scoped_ptr type to idiomatic C++11
std::unique_ptr, similar to the changes in the protobuf commit.
This has been tested on protobuf 3.0.0 (the version currently in Debian)
as well as the latest protobuf 3.6.1 release.
The xenial Travis-CI environment uses a g++ version that is old enough
that it doesn't use C++11 or newer by default, so we have to force it by
setting CXX to "g++ -std=c++11".
This is needed because in the syntax of Google protobuf the zero
value is not valid tag value. The specification
(https://developers.google.com/protocol-buffers/docs/proto3) says
that "The smallest tag number you can specify is 1, and the largest
is 2^29-1, or 536,870,911."
The change in commit 712154b912de824741381c0bb26c2fbed54515a3 ("Bump
minimum required header version for proto3 syntax") uses functionality
only exposed by protobuf-3.x, breaking the build when compiling against
protobuf-2.x.
Since we still want to support building against protobuf-2.x, this
commit makes the proto3 syntax check in the file generator dependent on
building against protobuf-3.x.