Subject: Re: [boost] [array] Invalid data: accessing 'elems'
From: Niels Dekker - address until 2010-10-10 (niels_address_until_2010-10-10_at_[hidden])
Date: 2010-09-06 06:16:31
Mateusz Loskot wrote:
> On 04/08/10 08:51, Niels Dekker wrote:
>> I can think of a few possible options:
>> * Add #pragma warning(disable: 6385) to boost/array.hpp
>> * Or add an __analysis_assume call to boost::array::operator:
>> reference operator(size_type i)
>> BOOST_ASSERT( i < N && "out of range" );
>> __analysis_assume(i < N);
>> return elems[i];
>> * Or add __analysis_assume(expr) to the BOOST_ASSERT(expr) macro
>> itself... (boost/assert.hpp)?
> I'd second the first or the second option as they are more explicit,
> thus self-documenting.
> The third option would hide this issue behind BOOST_ASSERT.
I think all three options are okay. What do you mean by "the third option
would hide this issue"? The BOOST_ASSERT already states explicitly that
operator(i) *assumes* i < N, right?
I guess a modification of BOOST_ASSERT might need some more discussion,
-- Niels Dekker http://www.xs4all.nl/~nd/dekkerware Scientific programmer at LKEB, Leiden University Medical Center
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk