Liste des Groupes | Revenir à cl c |
On 2025-04-16, bart <bc@freeuk.com> wrote:
(Yeah. Backend problem which hardcoded signed compared. 'for' iteration has its own IL instruction.)language:Exactly, small n.
>
for i in i64.max-10 .. i64.max do println i
which doesn't stop (u64 is OK however).What? That's a boogy bug.
I can make it implementation-defined since the behaviour can be predicted on the targets I will use. But in the language, if the natural wrap on overflow gives unexpected results, then you have a program bug.That doesn't worry me too much,I will frame these words next time you cricize C of taking some
I can just add a Note to the language spec warning of UB when a for-loop
bound is at the limits of the type.
easy way out and shirking doing the Right Thing with UB.
How do you fix overflow of A * B?Where all sorts of other stuff canYou can fix all the other stuff at the language level also.
happen because of how values wrap.
I am in the C camp (I said exactly that a few days ago). I just don't like the way the visible language was designed, and think there are too many unreasonable UBs.I don't understand why you're not in the C camp with these words.Then we can do>
>
for (int i = INT_MIN; : i < INT_MAX; i++)
>
After the last iteration, i is INT_MAX, and so the test fails.
The loop terminates without performing i++.
>
You're trying too hard. I don't think the language needs to bother
providing solutions, it just needs to specify the limitations.
Les messages affichés proviennent d'usenet.