Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2019-07-19 11:03:09


navya deepika garakapati wrote:

> Hi Devs,
> consider below reduced testcase from boost lamda.
>
> $cat result_of_tests.cpp
>
> #include <boost/lambda/lambda.hpp>
> #include <stdio.h>
> template<class A, class F> typename boost::result_of<F(A)>::type apply1(F
> f, A b) {
> return f(b);
> }
> using namespace boost::lambda;
> int main(int, char *[]) {
> int one = 1;
> int d= (apply1<int>(_1 ,one) == 1);
> printf("\n%d\n",d);
> return 0;
> }

f(b) returns a reference to b, which goes out of scope at the closing brace;
the example has undefined behavior. You should report this as an issue at
https://github.com/boostorg/lambda/issues.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk