Rational Developer for System z
Enterprise PL/I for z/OS, Version 3.8, Migration Guide

IBM2622: warning on poorly coded DO loops

When compiling some of your "working" code, you may also now see this more obscure message:

  IBM2622I W   ENTRY used to set the initial value in a DO loop will
               be invoked after any TO or BY values are set.

The new compiler will produce this message for code such as the following:

   dcl jx    fixed bin;
   dcl last  fixed bin init(10);

   do jx = f() to last;
     put skip list( jx );
   end;

   f: proc returns( fixed bin );
     last = 4;
     return( 2 );
   end;

Note that in this code the function f that sets the initial value in the loop also changes the value of the variable last that sets the final value in the loop. The message is alerting you to the fact that this change to the variable last will be made after the compiler has already used that variable to set the final value for the loop. In the concrete terms of this example, the loop will run from 2 to 10, not 2 to 4.

This is different than what the old compiler would have done for such code: under the compiler, this loop would have run from 2 to 4.

So to make this code behave the same as it did under the old compiler, it would be necessary for you to change your source code. This would be a good idea in any case since it is not good programming practice to have functions that have side effects such as changing other variables in their calling routine. The code as written above is also not very transparent, and unclear code with obscure effects is never good.


Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)