Space Engineers


BUG OF THE MONTH | Strange loops

V3028 Consider inspecting the ‘for’ operator. Initial and final values of the iterator are the same. VRage.Render MyRender-Management.cs 1034

internal static void 
AddDivisionForCullingStructure(List<MyRenderObject> roList, 
                               int objectCountLimit, 
                               List<BoundingBoxD> resultDivision)
  for (int axis = bestAxis; axis <= bestAxis; axis++)

The loop counter axis is initialized to the value of bestAxis, but because the same value (or less) is also used as the loop termination condition, the loop won’t iterate at all. The programmer actually wanted the counter to start with 0, in which case the loop should be rewritten as follows:

for (int axis = 0; axis <= bestAxis; axis++)

Please click here to see more bugs from this project.

One thought on “Space Engineers

  1. Actually, the loop would have iterated at least once since the condition is <= (less than or equal), so it's unclear if starting with 0 is what is wanted.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.