id summary reporter owner description type status milestone component version severity resolution keywords cc
10493 Since 1.56, any_range with non-reference references can cause UB nofitserov@… Neil Groves "This must be related to #10360. This is a regression since 1.55.
When using any_range, mutable dereference() method returns mutable_reference_type_generator::type, which becomes T&. So dereference() returns a dangling reference to an on-the-fly computed value.
See attached test case, which works with 1.55, and fails with -fsanitize=address on Clang 3.5 with 1.56.
{{{
#include
#include
#include
#include
typedef boost::any_range<
std::string,
boost::forward_traversal_tag,
std::string,
std::ptrdiff_t
> range_t;
std::string f(std::string a)
{
return a + ""!"";
}
int main()
{
std::vector v = {""a"", ""b""};
range_t r = v | boost::adaptors::transformed(f);
for (auto&& a : r)
std::cout << a << std::endl;
return 0;
}
}}}
" Bugs assigned Boost 1.64.0 range Boost 1.62.0 Regression p.omta@…