Fix gcc warnings on main that cause build errors.

There are two issues here related to recent changes:
1) Our extern declarations of common RepeatedField types were removed, allowing RepeatedField::Reserve to get inlined.  This results in an `array-bounds` warning from gcc due to our memcpy call.  We had an explicit comment that this method shouldn't be inlined, and that silences the warning.

2) Using std::inserter with flat_hash_set::end() triggers a `maybe-uninitialized` warning from gcc.  This is likely an Abseil issue, and showed up recently as part of our effort to migrate to the more efficient Abseil containers.  Alternatively inserting into flat_hash_set::begin() works just fine and avoids this issue.

PiperOrigin-RevId: 501301957
pull/11472/head
Mike Kruskal 2 years ago committed by Copybara-Service
parent 9244d121b4
commit 97da3fbb9d
  1. 2
      src/google/protobuf/compiler/objectivec/file.cc
  2. 2
      src/google/protobuf/repeated_field.h

@ -185,7 +185,7 @@ FileGenerator::CommonState::CollectMinimalFileDepsContainingExtensionsInternal(
absl::flat_hash_set<const FileDescriptor*> min_deps;
std::copy_if(min_deps_collector.begin(), min_deps_collector.end(),
std::inserter(min_deps, min_deps.end()),
std::inserter(min_deps, min_deps.begin()),
[&](const FileDescriptor* value) {
return to_prune.find(value) == to_prune.end();
});

@ -935,7 +935,7 @@ inline int CalculateReserveSize(int total_size, int new_size) {
// Avoid inlining of Reserve(): new, copy, and delete[] lead to a significant
// amount of code bloat.
template <typename Element>
void RepeatedField<Element>::Reserve(int new_size) {
PROTOBUF_NOINLINE void RepeatedField<Element>::Reserve(int new_size) {
if (total_size_ >= new_size) return;
Rep* old_rep = total_size_ > 0 ? rep() : nullptr;
Rep* new_rep;

Loading…
Cancel
Save