dotnet / dotnet/dotnet-api-docs

Mention self-insertion UB in docs of `CollectionExtensions.InsertRange`

Open
#10,388 1 comment 0 reactions 0 assignees View on GitHub
area-System.Collections Pri3 untriaged
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

### Describe the issue or suggestion

https://github.com/dotnet/runtime/blob/102f28e5a64cdbe89484ac10414fdebb9a51c65f/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/CollectionExtensions.cs#L140-L141

Per code, inserting a span from a `List` into itself is UB. I think we should mention it in the [docs](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.collectionextensions.insertrange?view=net-8.0), because `List.InsertRange(itself)` does work but the Span version doesn't.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.