Fix build for older compilers.

If it doesn't properly do constant initialization on globals we should
not try to call virtual functions on these objects during dynamic
initialization.
Turn off the optimization in these cases.

PiperOrigin-RevId: 619251810
pull/16291/head
Protobuf Team Bot 8 months ago committed by Copybara-Service
parent b5e69ae141
commit f5c53ac460
  1. 8
      src/google/protobuf/extension_set.cc
  2. 4
      src/google/protobuf/extension_set.h

@ -154,7 +154,13 @@ void ExtensionSet::RegisterMessageExtension(const MessageLite* extendee,
type == WireFormatLite::TYPE_GROUP); type == WireFormatLite::TYPE_GROUP);
ExtensionInfo info(extendee, number, type, is_repeated, is_packed, ExtensionInfo info(extendee, number, type, is_repeated, is_packed,
verify_func, is_lazy); verify_func, is_lazy);
info.message_info = {prototype, prototype->GetTcParseTable()}; info.message_info = {prototype,
#if defined(PROTOBUF_CONSTINIT_DEFAULT_INSTANCES)
prototype->GetTcParseTable()
#else
nullptr
#endif
};
Register(info); Register(info);
} }

@ -140,7 +140,9 @@ struct ExtensionInfo {
struct MessageInfo { struct MessageInfo {
const MessageLite* prototype; const MessageLite* prototype;
// The TcParse table used for this object. Never null. // The TcParse table used for this object.
// Never null. (except in platforms that don't constant initialize default
// instances)
const internal::TcParseTableBase* tc_table; const internal::TcParseTableBase* tc_table;
}; };

Loading…
Cancel
Save