There's an orthogonal but related issue that might be worth mentioning.
Last I looked some of the natString.cc routines that involve this
bounds checking show up fairly high on profiles for SPECjbb and probably
also real code. Most of the bounds checking is done with tests like
if (a > b || c > d || e > f)
My guess would be that on most architectures, it would be better to compile
this as
if ((long)((b - a) | (d - c) | (f - e)) < 0)
i.e. or sign bits together, and do a single test and branch on the result.
This reduces the number of branches, and thus avoids filling up branch
prediction tables with this sort of stuff. It also clearly allows
all the expressions to be scheduled in parallel.