3 ms·
Where does the C# compiler erase an array bounds check? That would require the C# compiler to emit unsafe IL which wouldn't verify. The C# team has said they tr
by MichaelGG 14y ago
Where does the C# compiler erase an array bounds check? That would require the C# compiler to emit unsafe IL which wouldn't verify. The C# team has said they try for a fairly direct translation to MSIL; there's no super sophisticated optimization going in the C# compiler.
I think you mean the CLR/JIT often removes array checks if it can detect it (such as in certain loop constructs).
Please correct me if I'm wrong.
- pjmlp 14y agoYes, the JIT/NGEN takes care of if it it can prove by dataflow analysis that the indexes are always within bounds.