Make the TcParser tables constexpr.

Without it some compilers will not constant initialize the tables and cause
runtime failures during registration. We must be able to parse descriptors
during dynamic initialization.

PiperOrigin-RevId: 529092745
pull/12472/head
Protobuf Team Bot 2 years ago committed by Copybara-Service
parent 701e056e2b
commit 7b22c57cef
  1. 3
      src/google/protobuf/compiler/cpp/parse_function_generator.cc

@ -406,8 +406,7 @@ void ParseFunctionGenerator::GenerateTailCallTable(Formatter& format) {
// unknown fields and potentially an extension range.
auto field_num_to_entry_table = MakeNumToEntryTable(ordered_fields_);
format(
"PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1\n"
"const ::_pbi::TcParseTable<$1$, $2$, $3$, $4$, $5$> "
"constexpr ::_pbi::TcParseTable<$1$, $2$, $3$, $4$, $5$> "
"$classname$::_table_ = "
"{\n",
tc_table_info_->table_size_log2, ordered_fields_.size(),

Loading…
Cancel
Save