Internal change
PiperOrigin-RevId: 813877809
diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc
index ce7af2c..ddd411f 100644
--- a/src/google/protobuf/port_def.inc
+++ b/src/google/protobuf/port_def.inc
@@ -797,6 +797,13 @@
#define PROTOBUF_NULLABLE
#endif
+#ifdef PROTOBUF_NO_MERGE
+#error PROTOBUF_NO_MERGE was previously defined
+#endif // PROTOBUF_NO_MERGE
+#ifndef PROTOBUF_NO_MERGE
+#define PROTOBUF_NO_MERGE
+#endif // PROTOBUF_NO_MERGE
+
#ifdef PROTOBUF_PRESERVE_ALL
#error PROTOBUF_PRESERVE_ALL was previously defined
#endif // PROTOBUF_PRESERVE_ALL
diff --git a/src/google/protobuf/port_undef.inc b/src/google/protobuf/port_undef.inc
index e904c8c..ca6a6b8 100644
--- a/src/google/protobuf/port_undef.inc
+++ b/src/google/protobuf/port_undef.inc
@@ -68,6 +68,7 @@
#undef PROTOBUF_NULLABLE
#undef PROTOBUF_FUTURE_STRING_VIEW_DESCRIPTOR_DATABASE
#undef PROTOBUF_PRESERVE_ALL
+#undef PROTOBUF_NO_MERGE
#ifdef PROTOBUF_FUTURE_BREAKING_CHANGES
#undef PROTOBUF_FUTURE_BREAKING_CHANGES
diff --git a/src/google/protobuf/repeated_ptr_field.h b/src/google/protobuf/repeated_ptr_field.h
index 210e494..2c1fd29 100644
--- a/src/google/protobuf/repeated_ptr_field.h
+++ b/src/google/protobuf/repeated_ptr_field.h
@@ -108,7 +108,10 @@
PROTOBUF_EXPORT inline void RuntimeAssertInBounds(int index, int size) {
if constexpr (GetBoundsCheckMode() == BoundsCheckMode::kAbort) {
if (ABSL_PREDICT_FALSE(index < 0 || index >= size)) {
- LogIndexOutOfBoundsAndAbort(index, size);
+ // "No merge" attribute used to improve debuggability by telling the
+ // compiler not to merge these failure paths. Note that this is currently
+ // best-effort in clang/llvm.
+ PROTOBUF_NO_MERGE LogIndexOutOfBoundsAndAbort(index, size);
}
}
ABSL_DCHECK_GE(index, 0);