Subject: Re: [boost] [xpressive] Performance Tuning?
From: Christopher Jefferson (chris_at_[hidden])
Date: 2009-07-21 16:45:13
On 21 Jul 2009, at 21:35, Raindog wrote:
> Celtic Minstrel wrote:
>> On Tue, Jul 21, 2009 at 6:17 AM, Edward
>> Grace<ej.grace_at_[hidden]> wrote:
>> > // Will the following fail? It jolly well should!
>> > v = 2;
>> > cout << v.capacity() << " " << v.size() << endl;
>> > That's pure evil of course! I suppose that's a good reason for
>> always using
>> > .begin() and .end() rather than .begin() + N.
>> Correct me if I'm wrong, but it seems you're complaining that v
>> doesn't do bounds checking?
>> The standard does not require bounds checking on array subscript,
>> though it seems there's
>> nothing saying it shouldn't bounds check. But there's the alternate
>> v.at(5) notation if you do need
>> bounds checking.
>> "Celtic Minstrel"
>> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
> The issue is that v.begin(), v.begin()+5 should not be bounds
> checked, but by default in vc9 (vs 2008) it is. In vc10, the default
> is that it is not on by default.
No no, it's quite legal to bounds check it. As soon as you go past the
end of the vector, you are into undefined behaviour, and any kind of
nasty thing could happen.
In practice you might find your code works fine, but it's not
impossible some future case or optimisation will cause broken behaviour.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk