Skip to content

Commit 6d0c7d7

Browse files
[release/10.0] Address upcoming breaking change for span-valued collection expressions (#120774)
Backport of #120771 to release/10.0 /cc @RikkiGibson ## Customer Impact - [ ] Customer reported - [X] Found internally Customers could end up with incorrect behavior due to the backing storage for a collection expression having the wrong lifetime relative to the local that tracked it. ## Regression - [ ] Yes - [x] No C# took a late breaking change to fix a lifetime issue around collection expressions and the IL it was emitting. This behavior has been around since collection expressions were introduced. ## Testing Explicit validation of the IL was done. ## Risk Low. This is the only place in the repo that was impacted by the break and was updated to use an appropriate lifetime for the collection expression. Co-authored-by: Rikki Gibson <rigibson@microsoft.com>
1 parent 60629d1 commit 6d0c7d7

File tree

1 file changed

+2
-2
lines changed
  • src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore

1 file changed

+2
-2
lines changed

src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorShape.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ internal enum TensorFlags : uint
6868
private TensorShape(nint linearLength, scoped ReadOnlySpan<nint> lengths, scoped ReadOnlySpan<nint> strides, TensorFlags flags)
6969
{
7070
int rank = lengths.Length;
71-
71+
ReadOnlySpan<nint> rank0Lengths = [0];
7272
if (rank == 0)
7373
{
74-
lengths = [0];
74+
lengths = rank0Lengths;
7575
rank = 1;
7676
}
7777
Debug.Assert(rank >= 1);

0 commit comments

Comments
 (0)