Path: ...!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: jseigh Newsgroups: comp.arch Subject: Re: Computer architects leaving Intel... Date: Wed, 4 Sep 2024 08:53:08 -0400 Organization: A noiseless patient Spider Lines: 28 Message-ID: References: <2024Aug30.161204@mips.complang.tuwien.ac.at> <2024Aug30.195831@mips.complang.tuwien.ac.at> <2024Aug31.170347@mips.complang.tuwien.ac.at> <505954890d8461c1f4082b1beecd453c@www.novabbs.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Wed, 04 Sep 2024 14:53:08 +0200 (CEST) Injection-Info: dont-email.me; posting-host="54337a702529433b553e4ec243da3949"; logging-data="4032902"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18/thB7W4cUNEu5xVyJmg8B" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:Cn/juo5+8EgogJogOaxFPUJ/wk0= Content-Language: en-US In-Reply-To: Bytes: 2867 On 9/4/24 06:57, David Brown wrote: > On 04/09/2024 09:15, Terje Mathisen wrote: >> David Brown wrote: >> Maybe? >> >> Rust will _always_ check for such overflow in debug builds, then when >> you've determined that they don't occur, the release build falls back >> standard CPU behavior, i.e. wrapping around with no panics. > > But if you've determined that they do not occur (during debugging), then > your code never makes use of the results of an overflow - thus why is it > defined behaviour?  It makes no sense.  The only time when you would > actually see wrapping in final code is if you hadn't tested it properly, > and then you can be pretty confident that the whole thing will end in > tears when signs change unexpectedly.  It would be much more sensible to > leave signed overflow undefined, and let the compiler optimise on that > basis. > You absolutely do want defined behavior on overflow. There are algorithms that depend on that. Bakery algorithms for instance. Unless you think a real life bakery with service tickets numbering from 1 to 50 either never gets more than 50 customers in a day or closes after their 50th customer. :) Joe Seigh