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. 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. Regards, Nate