diff --git a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc index 46cb701f2e..a0bd2e4702 100644 --- a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc @@ -32,6 +32,7 @@ #include #include +#include #include "google/protobuf/compiler/code_generator.h" #include "absl/strings/str_cat.h" @@ -88,7 +89,8 @@ void PrimitiveFieldGenerator::GenerateMembers(io::Printer* printer) { variables_["default_value_access"] = absl::StrCat(property_name, "DefaultValue"); } else { - variables_["default_value_access"] = variables_["default_value"]; + std::string default_value = variables_["default_value"]; + variables_["default_value_access"] = std::move(default_value); } // Declare the field itself.