Toby Ewing wrote:
I mentioned yesterday that I was getting a compiler warning when I used Cards rather than Integers for Schema, and Frank wanted to know more. Below is a (remarkably familiar) test program.
... except last time you said "Card" which I interpreted as `Cardinal'. If you had mentioned the actual types you mean, it would have been more useful to me ...
When I compile the program, I get the warning: Warning: comparison is always "True" due to limited range of data type for the three "i" loops. Oddly enough, the "j" and "k" loops get no warning, though in other similar programs I've had warnings for each of nested loops.
It's because of the 1. At the start of the loop, the compiler compares the upper and lower bounds (only if <=, the loop is executed). So we have `0 <= nx' and `1 <= nx'. The first is always true. GPC warns for always true comparisons when written explictly by the user, but not in this case (but rather just skip the test). A slight bug made it still warn in some strange cases (which indeed depend on the types involved). Here's a fix (toby1.pas).
Frank