hoangduit / dotnetperls-controls

Automatically exported from code.google.com/p/dotnetperls-controls
0 stars 0 forks source link

Unroll loop notice #2

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hey :)

I'm referring to the first example of
http://dotnetperls.com/Content/Loop-Unwinding.aspx

The unrolled loop does work, however, the i < a.Length; i += 2 part should
have a notice about the upper array bounds. By adding one element to the
array, we are supposed to get some array boundary exception.

This problem can easily be solved in different ways, i'm positive you're
familiar with these.

Hope this message helps - kind regards,
mafutrct.

Original issue reported on code.google.com by mafutr...@googlemail.com on 2 Dec 2008 at 8:25

GoogleCodeExporter commented 9 years ago
Thanks mafutrct! You are absolutely correct that the +=2 part will go past the 
upper
bounds if it is odd. 

Often with this kind of code the array sizes are well understood (whether it is 
odd
or even). But I can certainly see this causing a bug.

Original comment by allen....@gmail.com on 4 Dec 2008 at 4:33

GoogleCodeExporter commented 9 years ago
"It is important that you only unwind loops so that the steps in the loops do 
not 
exceed the array bounds. The unwound loop above could have 2, 4, or 6 elements 
to 
loop over, but not 3, 5, or 7."

Original comment by allen....@gmail.com on 4 Dec 2008 at 4:42

GoogleCodeExporter commented 9 years ago
How do I get help with "Words with Friends"?
My screen shows I have a chat message and when I open it up there is nothing 
there. Does anyone know how to fix?

Original comment by 2020...@gmail.com on 5 Oct 2014 at 2:51