|
Boost : |
Subject: [boost] [Multiarray] & [Range] MSVC/gcc warning: returning address of local variable or temporary
From: John Reid (j.reid_at_[hidden])
Date: 2008-11-11 18:53:27
The following code generates a worrying warning under MSVC:
#include <boost/range/iterator_range.hpp>
#include <boost/multi_array.hpp>
typedef boost::multi_array< double, 1 > my_array;
typedef my_array::const_iterator it;
void test(const my_array & a) {
boost::iterator_range< it > it_range(a.begin(), a.begin() + 1);
it_range[0];
}
C:\Dev\ThirdParty\boost\boost_1_37_0\boost/range/iterator_range.hpp(356)
: warning C4172: returning address of local variable or temporary
C:\Dev\ThirdParty\boost\boost_1_37_0\boost/range/iterator_range.hpp(354)
: while compiling class template member function 'const double
&boost::iterator_range<IteratorT>::operator [](__w64 int) const'
with
[
IteratorT=it
]
iterator_range.cpp(8) : see reference to class template
instantiation 'boost::iterator_range<IteratorT>' being compiled
with
[
IteratorT=it
]
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?
Thanks,
John.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk