Subject: Re: [boost] [test] BOOST_TEST macro and std::max
From: Andrzej Krzemienski (akrzemi1_at_[hidden])
Date: 2016-01-11 04:51:15
2016-01-11 4:11 GMT+01:00 Gennadiy Rozental <rogeeff_at_[hidden]>:
> Benedek Thaler <thalerbenedek <at> gmail.com> writes:
> I believe at this point we understand WHAT is going on.
> > auto const& E = ::boost::test_tools::assertion::seed()->*3u
> > == ((std::max)(0u, 3u));
> max returns unsigned int&&, which for some unclear reason is bound to
> unsigned int const& in expression template E. This obviously becomes
> dangling reference as soon as we leave this line.
This is an expected behavior in C++: an xvalue (rvalue reference returned
from a function) can be bound to a const lvalue reference. See example:
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk