Subject: Re: [boost] [Multiarray] & [Range] MSVC/gcc warning: returning address of local variable or temporary
From: David Abrahams (dave_at_[hidden])
Date: 2008-11-11 23:44:56
on Tue Nov 11 2008, Steven Watanabe <watanabesj-AT-gmail.com> wrote:
> John Reid wrote:
>> The following code generates a worrying warning under MSVC:
>> I'm using msvc 8.0 express and boost 1.37.0 release. I've seen similar warnings from
>> gcc 4.3 on similar code. Is this a problem with boost.Multiarray, boost.range or the
>> compiler? My guess is that Multiarray has defined its iterators incorrectly. Can
>> anyone confirm this/provide a fix?
> This is the result of a bad interaction between
> iterator_range and iterator_facade.
> iterator_facade makes the result of operator an rvalue
> iterator_range assumes that operator for an iterator
> returns the type reference.
FWIW, iterator_range is in the wrong here. That is not a safe
assumption. It can, however, be checked for fairly reliably at
-- Dave Abrahams BoostPro Computing http://www.boostpro.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk