I think this is a bug in the implementation. Filed issue:
https://github.com/google/protobuf/issues/141

On Mon, Dec 15, 2014 at 11:47 PM, John Sun <ih4...@gmail.com> wrote:
>
> Hi all,
>
> As said in the official document [C++ Generated Code
> <https://developers.google.com/protocol-buffers/docs/reference/cpp-generated>::Singular
> String Fields]:
>
>
> <https://lh4.googleusercontent.com/-oYL7QapLFwA/VI_h8UnnW1I/AAAAAAAAAFs/EKBP3yHOz0s/s1600/0.png>
> But in my test, the string pointed by the returned pointer just has the
> default value. My test environment is Win764bit, Visual Studio 2013.
> Here is my test:
>
> *Message definition:*
>
>
> <https://lh6.googleusercontent.com/-r19642fX7_A/VI_ihF6yEhI/AAAAAAAAAF0/WgbNZeFnGEc/s1600/1.png>
>
> *Test code:(without set the string field before use its mutable pointer)*
>
>
> <https://lh5.googleusercontent.com/-w1aWpS9uEw4/VI_iuJuVDTI/AAAAAAAAAF8/XXMNOCrftE0/s1600/2.png>
>
> *Result:*
>
>
> <https://lh4.googleusercontent.com/-3JmIUw0XnFo/VI_jWmIiC1I/AAAAAAAAAGM/e7E6bKyC4NA/s1600/3.png>
>
> Why? Please notice me if I misunderstood the doc.
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to protobuf+unsubscr...@googlegroups.com.
> To post to this group, send email to protobuf@googlegroups.com.
> Visit this group at http://groups.google.com/group/protobuf.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to