-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Open
Labels
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMICLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIuntriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner
Description
https://godbolt.org/z/3arPqT9oP
public static bool Foo(ReadOnlySpan<char> span)
{
for (int i = 0; i < span.Length; i++)
{
if (span[i] == '%' && (uint)(i + 2) < (uint)span.Length)
{
if (span[i + 1] == 'F' && // Bounds check
span[i + 2] == 'F')
{
return true;
}
}
}
return false;
}(uint)i < (uint)span.Length && (uint)(i + 2) < (uint)span.Length implies that i + 1 is also in range.
E.g.
runtime/src/libraries/System.Private.Uri/src/System/Uri.cs
Lines 3682 to 3686 in 0ad494b
| if ((uint)(i + 2) >= (uint)uriString.Length || | |
| colonOffset == 0 || | |
| // Redundant checks to eliminate range checks below | |
| (uint)i >= (uint)uriString.Length || | |
| (uint)(i + 1) >= (uint)uriString.Length) |
or
https://github.com/MihaZupan/runtime/blob/299818ab507ff37b0ef74918fdc35463b7e2d5e1/src/libraries/System.Private.Uri/src/System/UriHelper.cs#L321-L325 from #121261
BoyBaykiller and EgorBo
Metadata
Metadata
Assignees
Labels
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMICLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIuntriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner