Labels: Type-Defect Priority-Medium
New issue 312 by big4...@gmail.com: Required field with default value
serializes if not set
What steps will reproduce the problem?
1. Create a simple proto file containing a required field with a default
value (see test.proto)
2. Make a testprogram in which the required field is not explicitly set,
then try to serialize the message (see test.cc)
3. Compile & Run
What is the expected output? What do you see instead?
I would expect the serialization to fail since IsInitialized() is false and
According to the documentation @
required fields must be set"
With test.cc however, it sais (correctly) that has_i() is false, and the
message is thus not initialized. The serialization to both Ostream and
String succeed however. Finally parsing from the generated(empty) string
fails as expected because there is no "i".
What version of the product are you using? On what operating system?
2.4.1 @ Ubuntu 10.04
protoc --version --> libprotoc 2.4.1
uname -a --> Linux UbuntuSan 2.6.32-30-generic #59-Ubuntu SMP Tue Mar 1
21:30:46 UTC 2011 x86_64 GNU/Linux
test.proto 51 bytes
test.cc 611 bytes
You received this message because you are subscribed to the Google Groups "Protocol
To post to this group, send email to firstname.lastname@example.org.
To unsubscribe from this group, send email to
For more options, visit this group at