Subject: Re: Bounding Indices in Sequence Functions
From: Erik Naggum <erik@naggum.no>
Date: 22 Oct 2002 17:16:01 +0000
Newsgroups: comp.lang.lisp
Message-ID: <3244295761850806@naggum.no>

* Barry Margolin
| There's nothing guaranteeing this.  It's not required to check that
| end<=length, and if it doesn't check you can get a buffer overflow (like
| the kind that have been the cause of so many security problems).

  That does not follow strictly from the premises.  The test for an actual
  index < length may well be performed without testing that end <= length.
  Although some CPU cycles may conceivably be saved by testing once, the
  test may also be performed in parallel with the actual memory access
  instruction in such a way that a test at the head of the loop would only
  waste resources and be obnoxious if the purpose of the function were to
  be satisfied before the condition became relevant.

-- 
Erik Naggum, Oslo, Norway

Act from reason, and failure makes you rethink and study harder.
Act from faith, and failure makes you blame someone and push harder.