[M3devel] range analysis?

Tony Hosking hosking at cs.purdue.edu
Mon May 23 16:31:24 CEST 2011


An empty subrange gives a warning in the compiler.
But, the semantics is that it is empty, and has no values of the type.
You cannot allocate (NEW) an empty type.
You cannot declare a field of empty type.
Nor can you declare a variable of empty type.

On May 23, 2011, at 8:41 AM, Hendrik Boom wrote:

> On Sun, May 22, 2011 at 11:18:02PM +0000, Jay K wrote:
>> 
>> Well, I can build the whole tree and see how many times it helps.
>> I think this is a pretty standard optimization technique.
>> Though it'd work better with compiler-derived additional information.
>> 
>> I initially happened upon this idea developing test cases.
>> 
>>> The code assumes the minimum of a type is less than or equal to its maximum.
>> 
>> I'll change it not have that problem -- to just fall back to usual pessimistic code for such types, I guess.
> 
> What *is* the semantics of a range whose minimum is greater than its 
> maximum?  There plainly can't be any values in this range.  How is a 
> variable of this tyoe initialized?  Not to some arbitrary value of the 
> type, because there aren't any.  I can see this type being useful to 
> admit convenient generalizations -- for example, an array with n 
> elements can still exist if n happens to be zero, but it seems to me 
> that any code involving a value of the range for subscripts for this 
> array must be simple unexecutable.
> 
> Or is there some latitude available in the principle that a value of a 
> variable must always be of the correct type?
> 
> -- hendrik




More information about the M3devel mailing list