You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
IndexOutOfRangeException in HashSet.EnsureCapacity method #30698
Activity
scalablecory commentedon Aug 27, 2019
Are you seeing an exception thrown? It looks like this should not be an issue:
https://github.com/dotnet/corefx/blob/2a0f48da86297f9e60f5f5257dbb7eee1cbb5a3e/src/System.Collections/src/System/Collections/Generic/HashSet.cs#L1735-L1742
omariom commentedon Aug 27, 2019
Yep
stephentoub commentedon Aug 28, 2019
It's not that the actual hash codes can be negative. It's that SetCapacity isn't taking the free list into account.
scalablecory commentedon Aug 28, 2019
@stephentoub yup, have a fix incoming.
Fix HashSet.SetCapacity() that increases capacity failing after a suc…
scalablecory commentedon Aug 28, 2019
This bug has existed since 2.1 -- it seems nobody is using this method in this way.
Fix HashSet.SetCapacity() that increases capacity failing after a suc…
scalablecory commentedon Aug 28, 2019
The fix is in for .NET 5. Thanks for the report.
danmoseley commentedon Aug 28, 2019
Does Dictionary have a test for this?