aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/compiler/cpp/cpp_string_field.cc
diff options
context:
space:
mode:
authorGravatar Nobuaki Sukegawa <nsukeg@gmail.com>2014-11-29 22:03:31 +0900
committerGravatar Nobuaki Sukegawa <nsukeg@gmail.com>2014-12-03 23:41:40 +0900
commit2413cb57efd31983b810cb256cdb48d9b8a062fb (patch)
treeb36be974d08cc02aeec3720a8c1e6f7176d175e3 /src/google/protobuf/compiler/cpp/cpp_string_field.cc
parent4470dcba6c41a9fcb749d69b1414d7b75991bdc1 (diff)
Make C++ string oneof field compatible with C++11
string oneof field was generated into "const ArenaStringPtr" field inside "default_oneof_instance_" struct (of name "<class name>OneofInstance"). On the other hand, in C++11, const field of type with trivial default constructor causes enclosing type's implicit default constructor to be deleted. Since ArenaStringPtr has tirvial default constructor, this caused default constructor of "default_oneof_instance_" struct to be deleted, making the constructor call inside generated code invalid and fail to compile.
Diffstat (limited to 'src/google/protobuf/compiler/cpp/cpp_string_field.cc')
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_string_field.cc3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/google/protobuf/compiler/cpp/cpp_string_field.cc b/src/google/protobuf/compiler/cpp/cpp_string_field.cc
index a7f95044..04ed08c9 100644
--- a/src/google/protobuf/compiler/cpp/cpp_string_field.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_string_field.cc
@@ -613,8 +613,7 @@ GenerateSwappingCode(io::Printer* printer) const {
void StringOneofFieldGenerator::
GenerateConstructorCode(io::Printer* printer) const {
printer->Print(variables_,
- " const_cast< ::google::protobuf::internal::ArenaStringPtr*>("
- "&$classname$_default_oneof_instance_->$name$_)->UnsafeSetDefault("
+ " $classname$_default_oneof_instance_->$name$_.UnsafeSetDefault("
"$default_variable$);\n");
}