Skip to content

Commit e7a3457

Browse files
Clarify undefined behavior for [ReadOnly]Span<T>(void*,int) constructors (#9670)
* Update Span`1.xml For #861 * Update ReadOnlySpan`1.xml For #861 * Update ReadOnlySpan`1.xml Per @stephentoub * Update Span`1.xml Per @stephentoub
1 parent 5177084 commit e7a3457

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

xml/System/ReadOnlySpan`1.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,9 @@ A `ReadOnlySpan<T>` instance is often used to reference the elements of an array
217217
<param name="length">The number of <typeparamref name="T" /> elements to be included in the <see cref="T:System.ReadOnlySpan`1" />.</param>
218218
<summary>Creates a new <see cref="T:System.ReadOnlySpan`1" /> from a specified number of <typeparamref name="T" /> elements starting at a specified memory address.</summary>
219219
<remarks>
220-
<format type="text/markdown"><![CDATA[This constructor should be used with care, since it creates arbitrarily typed `T`s from a block of memory.]]></format>
220+
<format type="text/markdown"><![CDATA[
221+
This constructor should be used with care, since it creates arbitrarily typed `T`s from a `void*`-typed block of memory, and neither `pointer` nor `length` are validated by the constructor.
222+
]]></format>
221223
</remarks>
222224
<exception cref="T:System.ArgumentException">
223225
<paramref name="T" /> is a reference type or contains references and therefore cannot be stored in unmanaged memory.</exception>

xml/System/Span`1.xml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,8 @@ If `array` is `null`, this constructor returns a `null` `Span<T>`.
208208
<summary>Creates a new <see cref="T:System.Span`1" /> object from a specified number of <typeparamref name="T" /> elements starting at a specified memory address.</summary>
209209
<remarks>
210210
<format type="text/markdown"><![CDATA[
211-
212-
This constructor should be used with care, since it creates arbitrarily typed `T`s from a `void*`-typed block of memory, and `length` is not checked. However, if the constructor succeeds in creating a new <xref:System.Span%601> object, all subsequent uses are correct.
213-
214-
]]></format>
211+
This constructor should be used with care, since it creates arbitrarily typed `T`s from a `void*`-typed block of memory, and neither `pointer` nor `length` are validated by the constructor.
212+
]]></format>
215213
</remarks>
216214
<exception cref="T:System.ArgumentException">
217215
<paramref name="T" /> is a reference type or contains pointers and therefore cannot be stored in unmanaged memory.</exception>

0 commit comments

Comments
 (0)