On 20 Nov 2002 at 14:10, Emil Jerabek wrote:
[...]
Now, where is the compiler going to get the values of minval and maxval? To do so it would have to read a, and translate that somehow into minval and maxval at run time. Where are those tables stored? Nothing insists that a be a valid initialized value before storing something in onebyte. Remember, onebyte and twobyte have the same offsets. They can store different subranges. a may have been set in another procedure far, far away.
Don't understand this. The problem was to check that the component accessed is valid, which is as simple as ``r.a = 1?'' in your example. Anyway the range check which you seem to be talking about is also easy: the code stores something into r.twobyte, hence the value should be range-checked against the definition of twobyte, i.e. minval = -5 and maxval = 512. These bounds are known at compile time, and they have nothing to do with the current value of r.a.
I think I understand the point being made. If you write something like "r.a := b;", how does the compiler perform the range check (either at compile time or at runtime)? The value of "b" could be anything and might have been set at any point in the code, in any number of ways (which might not be obvious at compile time, because it might depend on user input). And, presumably, "b" might be a 16- bit integer, and so the value of "b" could be "19000" or whatever. Or am I missing something?
Best regards, The Chief --------- Prof. Abimbola Olowofoyeku (The African Chief) Web: http://www.bigfoot.com/~african_chief/