Subject: Re: [boost] [array] Invalid data: accessing 'elems'
From: Mateusz Loskot (mateusz_at_[hidden])
Date: 2010-09-04 14:52:55
On 04/08/10 08:51, Niels Dekker - address until 2010-10-10 wrote:
> On 2010-08-02-Mon 18:29, Mateusz Loskot wrote:
>> Shall I report a ticket?
> Do you have a proposed fix?
Actually, I'm asking for suggestions :-)
> 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)?
> What do you think?
I'd second the first or the second option as they are more explicit,
The third option would hide this issue behind BOOST_ASSERT.
> BTW, the following compiler bug report seems related: Microsoft Visual
> Studio bug report ID 281033, "False warning C6385 when a function result
> is used as an array index",
-- Mateusz Loskot, http://mateusz.loskot.net Charter Member of OSGeo, http://osgeo.org
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk