Liste des Groupes | Revenir à cl c |
On 17/04/2025 03:18, Keith Thompson wrote:
My experiments show that:If you want to implement, say, an Ada-style for loop, detectingDoes it define what value I has when the loop terminates, or is the scope of I local to the loop body?
overflow is not an issue at the language level. The issue is that
for the following (I think the Ada syntax is clear enough):
>
for I in Integer'Last-1 .. Integer'Last loop
// whatever
end loop;
>
the language semantics specify that the body of the loop must be
executed with I equal to Integer'Last-1, and then with I equal to
Integer'Last. It's the compiler's job to figure out how to do that,
either without triggering an overflow or by handling it cleanly enough
that it doesn't change the behavior.
Les messages affichés proviennent d'usenet.