
Michael Stevens wrote:
The test case is very simple.
#include <boost/numeric/interval.hpp> #include <boost/minmax.hpp>
int main() { boost::numeric::interval<float> a,b,c; c = boost::std_max(a, a); }
gcc (2.95.3 and 3.3.1) is only warning "returning reference to temporary". I am surprised this doesn't show up in more cases. Why gcc thinks it needs a temporary here is beyond me
Yup, Dave anticipated this problem, and fixing it is on my To-Do list. The problem is due to the fact that max is overloaded for the interval type to return a non-reference: template<class T, class Policies> inline interval<T, Policies> max (const interval<T, Policies>& x, const interval<T, Policies>& y) { typedef interval<T, Policies> I; if (interval_lib::detail::test_input(x, y)) return I::empty(); return I(std_max(x.lower(), y.lower()), std_max(x.upper(), y.upper()), true); } The fix is to detect whether the unqualified call to max returns an lvalue or not and define the return type of std_max appropriately. Easy enough. What strikes me as odd with this overload, though, is that max(a,b) in this case will return something that is not equal to either a or b. That seems counter-intuitive. Is this right? -- Eric Niebler Boost Consulting www.boost-consulting.com