From e3c807d4e752b477b707f5d021264faf9b127304 Mon Sep 17 00:00:00 2001 From: Bo Yang Date: Fri, 23 Jun 2017 12:56:44 -0700 Subject: Fix more implicit type conversions in public headers and generated code. --- src/google/protobuf/compiler/cpp/cpp_message.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/google/protobuf/compiler/cpp/cpp_message.cc') diff --git a/src/google/protobuf/compiler/cpp/cpp_message.cc b/src/google/protobuf/compiler/cpp/cpp_message.cc index d9524f64..1ab87638 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message.cc +++ b/src/google/protobuf/compiler/cpp/cpp_message.cc @@ -2308,12 +2308,13 @@ void MessageGenerator::GenerateConstructorBody(io::Printer* printer, if (copy_constructor) { pod_template = "::memcpy(&$first$_, &from.$first$_,\n" - " reinterpret_cast(&$last$_) -\n" - " reinterpret_cast(&$first$_) + sizeof($last$_));\n"; + " static_cast(reinterpret_cast(&$last$_) -\n" + " reinterpret_cast(&$first$_)) + sizeof($last$_));\n"; } else { pod_template = - "::memset(&$first$_, 0, reinterpret_cast(&$last$_) -\n" - " reinterpret_cast(&$first$_) + sizeof($last$_));\n"; + "::memset(&$first$_, 0, static_cast(\n" + " reinterpret_cast(&$last$_) -\n" + " reinterpret_cast(&$first$_)) + sizeof($last$_));\n"; } for (int i = 0; i < optimized_order_.size(); ++i) { @@ -2750,8 +2751,9 @@ GenerateClear(io::Printer* printer) { FieldName(optimized_order_[memset_run_end]); printer->Print( - "::memset(&$first$_, 0, reinterpret_cast(&$last$_) -\n" - " reinterpret_cast(&$first$_) + sizeof($last$_));\n", + "::memset(&$first$_, 0, static_cast(\n" + " reinterpret_cast(&$last$_) -\n" + " reinterpret_cast(&$first$_)) + sizeof($last$_));\n", "first", first_field_name, "last", last_field_name); } -- cgit v1.2.3