|
Boost : |
Subject: Re: [boost] [Multiarray] & [Range] MSVC/gcc warning: returning address of local variable or temporary
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-11-11 19:38:23
AMDG
John Reid wrote:
> The following code generates a worrying warning under MSVC:
>
> <snip>
>
> 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
http://www.boost.org/libs/iterator/doc/iterator_facade.html#operator
iterator_range assumes that operator[] for an iterator
returns the type reference.
http://www.boost.org/libs/range/doc/utility_class.html#iter_range
In Christ,
Steven Watanabe
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk