Article View: comp.arch
Article #12Re: Optimization by programmers
From: Michael S
Date: Wed, 07 Oct 2026 19:25
Date: Wed, 07 Oct 2026 19:25
47 lines
2914 bytes
2914 bytes
On Mon, 5 Oct 2026 11:36:59 -0000 (UTC) cross@spitfire.i.gajendra.net (Dan Cross) wrote: > In article <86h5j5pky9.fsf@linuxsc.com>, > Tim Rentsch <tr.17687@z991.linuxsc.com> wrote: > >Terje Mathisen <terje.mathisen@tmsw.no> writes: > > > >> Tim Rentsch wrote: > >> > >>> Terje Mathisen <terje.mathisen@tmsw.no> writes: > >>> > >>>> Tim Rentsch wrote: > >[...] > >>>>> I favor a type equivalent to size_t for use as array index > >>>>> variables. > >>>> > >>>> In Rust, the only acceptable array index is of type "usize", > >>>> which is effectively the same as u64 on most platforms these > >>>> days, but does not need to be so: On a 32-bit target, it would > >>>> be the same as u32. > >>>> > >>>> So effectively very similar to size_t. > >>> > >>> Maybe that limitation works okay in Rust. In C sometimes it's > >>> important to allow a signed value for indexing. Probably 99% of > >>> the time size_t is good, but not always. > >> > >> The fact that array indices are unsigned is one of the more crucial > >> underpinnings of Rust safety. Even more importantly, all such > >> indices are verified against the actual array upper boundary. > >> [...] > > > >It's nice that array index values are checked against the array > >bounds. > > Terje was actually incorrect here; bounds checks are added in > debug mode, but are (usually) removed in optimized builds. > Are you sure? Methinks The Book states otherwise: https://doc.rust-lang.org/book/ch03-02-data-types.html?highlight=array#invalid-array-element-access
Technical Details
Message-ID:
<20261007222539.000033d0@yahoo.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mailReferences:
<1177fdi$26ea4$1@dont-email.me> <86bj9hr91x.fsf@linuxsc.com> <119dne7$2baig$1@dont-email.me> <86h5j5pky9.fsf@linuxsc.com> <11a024r$f52$1@reader2.panix.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Michael S <already5chosen@yahoo.com> Newsgroups: comp.arch Subject: Re: Optimization by programmers Date: Wed, 7 Oct 2026 22:25:39 +0300 Organization: A noiseless patient Spider Lines: 47 Message-ID: <20261007222539.000033d0@yahoo.com> References: <1177fdi$26ea4$1@dont-email.me> <86bj9hr91x.fsf@linuxsc.com> <119dne7$2baig$1@dont-email.me> <86h5j5pky9.fsf@linuxsc.com> <11a024r$f52$1@reader2.panix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Injection-Date: Wed, 07 Oct 2026 19:25:44 +0000 (UTC) Injection-Info: dont-email.me; logging-data="2438720"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18151r+h6Fj/EOiaMf0q3U/k+3gewgmXwg="; posting-host="ad05b586a96bfaffcf8a26253a6ce825" Cancel-Lock: sha1:75pkL9EHWtBocd3T3UsGajnxqik= sha256:IV/FWnoL455MAukvDTU+HHCS7CLfWW+LdDZq8RHZ/Ek= sha1:9hb4qxOYgPibW8tJIkU7Ur1NY2Q= sha256:4SszMOU9iszZ8SHQaWbM8BKIjTq4qWvqVTKCscmd6RU= X-Newsreader: Claws Mail 4.1.1 (GTK 3.24.34; x86_64-w64-mingw32)