From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8a4455177648cb9e X-Google-Attributes: gid103376,public From: Stephen Leake Subject: Re: Idea: Array Boundary Checks on Write Access Only Date: 1998/06/17 Message-ID: #1/1 X-Deja-AN: 363582670 References: <35851B64.5BF271C4@cl.cam.ac.uk> Organization: NASA Goddard Space Flight Center -- Greenbelt, Maryland USA Newsgroups: comp.lang.ada Date: 1998-06-17T00:00:00+00:00 List-Id: Markus Kuhn writes: > Here is a suggestion for Ada compiler developers: > > Add a compiler configuration option that suppresses array index > boundary checks only for *read* access to array elements. > > Array boundary checks in Ada are a major advantage over C/C++ > and add a lot to the safety and debugability of the language. > However the checks are also a significant performance loss > unless they are deactivated. A useful compromise would be an > option that causes the compiler to add boundary checks only > when an array element is written, but not when it is read. > Out-of-boundary array write accesses are dangerous because they can > destroy other data structures and can cause failure inside completely > unrelated objects. Therefore, in security critical applications, > it is very desireable to deactivate for performance reasons > only the checks for the less dangerous read accesses that if > they go wrong should not cause malfunction within other objects. A bug is a bug. If you write your code with properly typed indices, a good compiler can optimize away all array index checks, at least for statically sized constrained arrays. If you are using true dynamically sized or unconstrained arrays, you either need to have the compiler do all the checks, or do them all yourself somewhere. In the later case, you can turn off the compiler checks. I don't see why a "read bug" is ever ok! > > Are there already Ada compilers around that do this? I hope not :). > > Markus > -- Stephe