I understand your viewpoint, but I think mine is also legitimate.
In my opinion, the fact that you assign an interval [5,10] to the variable X means that the variable X does not represent the value, it represents the range.
Since the ranges ARE identical, we can write Y = X.
I agree with you that this should be up to the language and thus, probably outside the scope of our standard.
From: stds-1788@xxxxxxxx [mailto:stds-1788@xxxxxxxx]
On Behalf Of Ian McIntosh
Sent: Wednesday, July 03, 2013 5:07 PM
To: stds-1788@xxxxxxxxxxxxxxxxx
Subject: Fw: A Level 2 query - X-X
I would count writing Y = X when you don't mean they are identical, just possibly different values in the same range, as a programming bug. It's up to this standard
or the language standard though.
I don't object much to either meaning. The important thing is that the meaning has to be carefully defined, people have to learn what it means, and optimizers have to understand it too. What
are they encouraged to do, what are they allowed to do, and what are they forbidden to do? Some optimizers will go ahead and do forbidden things unless they are modified. Forbidding some things efficiently may even need host language changes. Some of the
requirements and implications are not obvious and reasonable people can have opposite opinions, so it has to be defined either by 1788 or by each language binding. Leaving it up to each implementation is really looking for trouble.
- Ian McIntosh IBM Canada Lab Compiler Back End Support and Development
----- Forwarded by Ian McIntosh/Toronto/IBM on 07/03/2013 06:51 PM -----
This may be not OK, if we have two different values X and Y for which it so happens that their bounds coincide, so instead of saying Y = [5.0,10.0], a programmer may want to save
time and write Y = X, but these are still different quantities about which we cannot assume that the actual values are equal
I think it is safe to optimize X-X to 0, but NOT the other two examples
From: stds-1788@xxxxxxxx [mailto:stds-1788@xxxxxxxx]
On Behalf Of Ian McIntosh
Sent: Wednesday, July 03, 2013 12:19 PM
To: stds-1788@xxxxxxxxxxxxxxxxx
Subject: Re: A Level 2 query - X-X
For intervals it would be OK to do the same for
SUB = X - X;
(except for infinite bounds) because X is identical to X, and for
X = [5., 10.];
Y = X;
Z = X - Y;
because the value Y represents is identical to X and none of the bounds is infinite, and for
U = [5., 10.];
X = U;
Y = U;
Z = X - Y;
because X and Y are always identical,