Skip to content

Commit

Permalink
Register a shutdown delete for C++ feature defaults
Browse files Browse the repository at this point in the history
Fixes #14794

PiperOrigin-RevId: 583499526
  • Loading branch information
mkruskal-google committed Nov 17, 2023
1 parent c529459 commit 3d5c709
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/google/protobuf/descriptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1092,14 +1092,16 @@ bool AllowedExtendeeInProto3(const std::string& name) {
}

const FeatureSetDefaults& GetCppFeatureSetDefaults() {
static const FeatureSetDefaults* default_spec = [] {
auto* defaults = new FeatureSetDefaults();
internal::ParseNoReflection(
absl::string_view{PROTOBUF_INTERNAL_CPP_EDITION_DEFAULTS,
sizeof(PROTOBUF_INTERNAL_CPP_EDITION_DEFAULTS) - 1},
*defaults);
return defaults;
}();
static const FeatureSetDefaults* default_spec =
internal::OnShutdownDelete([] {
auto* defaults = new FeatureSetDefaults();
internal::ParseNoReflection(
absl::string_view{
PROTOBUF_INTERNAL_CPP_EDITION_DEFAULTS,
sizeof(PROTOBUF_INTERNAL_CPP_EDITION_DEFAULTS) - 1},
*defaults);
return defaults;
}());
return *default_spec;
}

Expand Down

0 comments on commit 3d5c709

Please sign in to comment.