[Moved to gcc list from gcc-patches].

> > So now objects can have values outside of their type?
> 
> If we accept that it is correct that TYPE_PRECISION is not synonymous
> with TYPE_MIN_VALUE and TYPE_MAX_VALUE, then, yes, objects can have
> values outside of their type (isn't that the whole point of
> check'valid, or whatever it is called?).  

As you say, I think we need to define the *precise* semantics of what it
means if a value of a variable is outside the range of TYPE_{MIN,MAX}_VALUE.
The simplest example of that is an uninitialized variable.

It can conceivably mean a number of things:

(1) The effect of such a value is undefined and the compiler may assume
any consequences when this occurs.

(2) The compiler can treat the variable as having any value in the range
given by its TYPE_PRECISION that is convenient, but need not choose the same
value every time.

(3) The same as (2) except that the same value must be chosen every
time (for example the actual value or one of the bounds).

I think the best approach is to use flags set by the front end to indicate
which of these is to be the case.  For C, I believe (1) is always the
proper meaning.  I don't know what it is for C++, Fortran, and Java.  For
Ada, (3) is the normal case, but there are many situation where the front
end can prove that (2) or (1) is acceptable.

Reply via email to