From 3abdf99eec319e36b29776cf4789642d4cf410f3 Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Fri, 20 Sep 2024 09:43:41 -0700 Subject: [PATCH] Use a pointer instead of a ref from C++ thunk. 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 --- src/google/protobuf/compiler/rust/message.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/google/protobuf/compiler/rust/message.cc b/src/google/protobuf/compiler/rust/message.cc index 6bdde9a95ca7..318ba2c3697d 100644 --- a/src/google/protobuf/compiler/rust/message.cc +++ b/src/google/protobuf/compiler/rust/message.cc @@ -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,