Boost logo

Boost :

Subject: Re: [boost] Range Adapters (map_keys, map_values) cause undefined behavior (segv, etc) when applied to R-Values, especially in the context of BOOST_FOREACH
From: Dean Michael Berris (dberris_at_[hidden])
Date: 2014-01-30 01:49:37


On Thu, Jan 30, 2014 at 12:41 PM, Nathan Ridge <zeratul976_at_[hidden]> wrote:
> Hi Igor,
>
> This is a known issue: see https://svn.boost.org/trac/boost/ticket/7630.
> (That bug talks about C++11 range-based for loops, but the issue with
> BOOST_FOREACH is the same).
>
> I'm not sure what the status of this bug is. Jeffrey Yasskin posted a
> patch to that bug which I reviewed over email, but I haven't heard
> from him about it since.
>

Why was the review not done on the bug? I'm tracking that bug and
would like to see it resolved, and it seems the patch is just fine.
Are there any issues still that need to be addressed elsewhere? What
can I do to help expedite this process?

> Note that if you use C++11, a workaround is to use boost::for_each
> with a lambda instead, so
>
> BOOST_FOREACH(SomeType v, range_rvalue | adaptor)
> {
> statements
> }
>
> turns into
>
> boost::for_each(range_rvalue | adaptor, [&](SomeType v)
> {
> statements
> });
>
> Since the temporary lives until the end of the statement, and the
> whole loop is contained within the statement, there is no more
> undefined behaviour.
>

This is not an acceptable solution to the original problem.

> Regards,
> Nate
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


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