Path: ...!3.eu.feeder.erje.net!feeder.erje.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Lawrence D'Oliveiro Newsgroups: comp.lang.c Subject: Re: C23 thoughts and opinions Date: Wed, 5 Jun 2024 07:14:37 -0000 (UTC) Organization: A noiseless patient Spider Lines: 27 Message-ID: References: <20240602110213.00003b25@yahoo.com> <20240602162914.0000648c@yahoo.com> <20240603120043.00003511@yahoo.com> <20240603225856.0000679d@yahoo.com> <3uq7O.9130$nd%8.1870@fx45.iad> <20240603221239.245@kylheku.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Wed, 05 Jun 2024 09:14:38 +0200 (CEST) Injection-Info: dont-email.me; posting-host="4516e25990465832a6742c15b1bf965a"; logging-data="923364"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+HGPet2vIe1y4TFZ38qmsL" User-Agent: Pan/0.158 (Avdiivka; ) Cancel-Lock: sha1:NMHPofpQxespw3wcNu9sVQSfSl4= Bytes: 2456 On Tue, 4 Jun 2024 12:48:31 -0500, BGB wrote: > Though, I do have some questionable experimental features, like a > compiler option to cause arrays and pointers to be bounds-checked, which > is sometimes useful in debugging (but in some cases can add bugs of its > own; also makes the binaries bigger and negatively effects performance, > ...). I remember some research being done into this, back in the days of Pascal. Remember that, in Pascal (and Ada), subranges exist as types in their own right, not just as bounds of arrays. And this allows the compiler to optimize array-bounds checks, and sometimes get rid of them altogether. E.g. type boundstype = 1 .. 10; var myarr : array [boundstype] of elttype; index : boundstype; With these definitions, an expression like myarr[index] doesn’t require any bounds-checking. Of course, assignments to index may require bounds-checking, depending on the types of values involved.