Skip to content

Commit

Permalink
Fix: gcc 9 -Warray-bounds warnings about memset() in generated code
Browse files Browse the repository at this point in the history
  • Loading branch information
vesavlad authored and acozzette committed Sep 29, 2020
1 parent 3d8943f commit d16bf91
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 46 deletions.
10 changes: 6 additions & 4 deletions src/google/protobuf/api.pb.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions src/google/protobuf/compiler/cpp/cpp_message.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2487,8 +2487,9 @@ void MessageGenerator::GenerateConstructorBody(io::Printer* printer,
" reinterpret_cast<char*>(&$first$_)) + sizeof($last$_));\n";
} else {
pod_template =
"::memset(&$first$_, 0, static_cast<size_t>(\n"
" reinterpret_cast<char*>(&$last$_) -\n"
"::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(\n"
" reinterpret_cast<char*>(&$first$_) - reinterpret_cast<char*>(this)),\n"
" 0, static_cast<size_t>(reinterpret_cast<char*>(&$last$_) -\n"
" reinterpret_cast<char*>(&$first$_)) + sizeof($last$_));\n";
}

Expand Down
5 changes: 3 additions & 2 deletions src/google/protobuf/compiler/plugin.pb.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 42 additions & 28 deletions src/google/protobuf/descriptor.pb.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions src/google/protobuf/duration.pb.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions src/google/protobuf/timestamp.pb.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions src/google/protobuf/type.pb.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d16bf91

Please sign in to comment.