Richard said:
Richard Harter wrote:
On Tue, 04 Dec 2007 10:40:18 +0000, Philip Potter
[snip]
This is quite true. To quote myself, the responsibility for
avoiding overflow rests with the programmer and not with the
compiler.
When you cannot even add two integers together without avoiding all
possibility of overflow, how do you propose the programmer achieves this?
The programmer does it by not adding two integers together if
their sum would overflow.
Where did that proviso come from? In the text you snipped:
This is quite true. To quote myself, the responsibility for
avoiding overflow rests with the programmer and not with the
compiler.
There is no "if their sum would overflow" proviso. Once a proviso
becomes "if their sum or any partial sum in any possible reordering
would overflow"
The point I am making is that your application of the as-if rule, taken
to its logical conclusion, results in /no/ summation at all having
defined behaviour, because
a+b
can be evaluated as
a+INT_MAX+b-INT_MAX
I was saying this to get an idea from you of where the line was drawn.
(To be honest, looking back on it it's not that relevant to what you
were saying. What was I thinking when I wrote it?)