Skip to content

Commit

Permalink
Fix compiler error with StrongReferenceToType()
Browse files Browse the repository at this point in the history
For some reason, Clang 19 appears to raise an error in some situations unless
we explicitly inline the implementation of `StrongPointer()` here.

PiperOrigin-RevId: 669373421
  • Loading branch information
acozzette committed Sep 9, 2024
1 parent 9deedf0 commit 8ea3bb1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/google/protobuf/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ inline PROTOBUF_ALWAYS_INLINE void StrongPointer() {
template <typename T>
inline PROTOBUF_ALWAYS_INLINE void StrongReferenceToType() {
static constexpr auto ptr = T::template GetStrongPointerForType<T>();
return StrongPointer<decltype(ptr), ptr>();
// This is identical to the implementation of StrongPointer() above, but it
// has to be explicitly inlined here or else Clang 19 will raise an error in
// some configurations.
asm(".reloc ., BFD_RELOC_NONE, %p0" ::"Ws"(ptr));
}
#else // .reloc
// Portable fallback. It usually generates a single LEA instruction or
Expand Down

0 comments on commit 8ea3bb1

Please sign in to comment.