Range based for loops and integer overflow #986
Replies: 3 comments 8 replies
-
|
@gingerBill Huh, that doesn't seem intended at all? It indeed just spins around and around. |
Beta Was this translation helpful? Give feedback.
-
|
Seems to me that it's treated as <256, so it'll overflow to zero. 0..0, infinite loop. |
Beta Was this translation helpful? Give feedback.
-
|
I have implemented the more "intuitive" behaviour now into the Odin compiler: #990 Previously, for i := x; i <= y; i += 1 {}Which will cause an infinite loop if The new behaviour acts like this: for i := x; i <= y; /**/ {
// body
if i == y {
break;
}
i += 1;
}If |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
While making range based loops for my own compiler I noticed an awkward case. The following loop will run forever in odin:
It's because the loop terminates when x is strictly larger than y, but that's not possible here.
Is this intended behavior? I'll probably leave it like this in my own toy compiler since it's easier to handle.
EDIT
I opened an issue for this: #990
Beta Was this translation helpful? Give feedback.
All reactions