Clarify how dangling pointers in span can become UB in C++
They are not UB on their own but they are when used in
arithmetic.
PiperOrigin-RevId: 540893054
diff --git a/docs/bindings/reference/pointers_and_references.md b/docs/bindings/reference/pointers_and_references.md
index ff136b8..69de6f5 100644
--- a/docs/bindings/reference/pointers_and_references.md
+++ b/docs/bindings/reference/pointers_and_references.md
@@ -129,12 +129,12 @@
C++ doesn't share these rules, and care must be taken when converting Rust
references to and from C++ pointers. For example, spans/slices are particularly
-error-prone: a Rust empty slice uses a dangling pointer (which is UB in C++),
-and a C++ empty span (often) uses nullptr (which is UB in Rust). To effectively
-use spans in FFI, one must either use non-native types, or perform a conversion
-operation which rewrites the pointer values. For that, we recommend using the
-conversion routines provided by Crubit support library (e.g. `impl
-From<string_view> for &[u8]`).
+error-prone: a Rust empty slice uses a dangling pointer (which produces UB in
+C++ when used in pointer arithmetic), and a C++ empty span (often) uses nullptr
+(which is UB in Rust). To effectively use spans in FFI, one must either use
+non-native types, or perform a conversion operation which rewrites the pointer
+values. For that, we recommend using the conversion routines provided by Crubit
+support library (e.g. `impl From<string_view> for &[u8]`).
TODO(b/271016831, b/262580415): Cover `rs_std::Slice<T>` and/or `rs_std::str`
above once these types are provided by Crubit.