Skip to content

System.Numerics.Tensors Incorrect IndexOutOfRangeException on empty slice #106536

@soerenwolfers

Description

@soerenwolfers

Description

new TensorSpan<double>(Array.Empty<double>()).Slice(new NRange[] { .. });

throws an IndexOutOfRangeException but should return an empty span.

Reproduction Steps

using System.Buffers;
using System.Diagnostics.CodeAnalysis;
using System.Numerics.Tensors;

namespace ConsoleApp1;

public abstract class Program
{
	[Experimental("SYSLIB5001")]
	public static void Main()
	{
		new TensorSpan<double>(Array.Empty<double>()).Slice(new NRange[] { .. });
	}
}

Expected behavior

Empty span

Actual behavior

Exception

Regression?

No response

Known Workarounds

No response

Configuration

.Net8, Ubuntu22, x64

Other information

No response

Metadata

Metadata

Assignees

Labels

area-System.Numerics.Tensorsin-prThere is an active PR which will close this issue when it is merged

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions