Skip to content

Commit

Permalink
Use a pointer instead of a ref from C++ thunk.
Browse files Browse the repository at this point in the history
While in practice a C++ ref and ptr will have the same ABI, since C doesn't have refs this gets flagged by -Wreturn-type-c-linkage. Note that this contrasts with the Rust side where C-ABI functions that take a pointer or ref are permitted and guaranteed to have the same ABI.

PiperOrigin-RevId: 676875775
  • Loading branch information
protobuf-github-bot authored and copybara-github committed Sep 20, 2024
1 parent 20eeda8 commit 3abdf99
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/google/protobuf/compiler/rust/message.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1399,10 +1399,10 @@ void GenerateThunksCc(Context& ctx, const Descriptor& msg) {
size_t $repeated_len_thunk$(google::protobuf::RepeatedPtrField<$QualifiedMsg$>* field) {
return field->size();
}
const $QualifiedMsg$& $repeated_get_thunk$(
const $QualifiedMsg$* $repeated_get_thunk$(
google::protobuf::RepeatedPtrField<$QualifiedMsg$>* field,
size_t index) {
return field->Get(index);
return &field->Get(index);
}
$QualifiedMsg$* $repeated_get_mut_thunk$(
google::protobuf::RepeatedPtrField<$QualifiedMsg$>* field,
Expand Down

0 comments on commit 3abdf99

Please sign in to comment.