This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115d. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2024-10-26
Because the reference __range in the expansion of a range-based for statement, as described in 8.6.5 [stmt.ranged] paragraph 1, is bound only to the top-level expression of range-init, the lifetime of temporaries created at lower levels in that expression expires before the body of the loop is reached, leading to dangling references. It would be helpful if the lifetime of those temporaries were extended over the entire statement.
(See also issue 1523 for another question regarding the rewritten form of the range-based for.)
Rationale (October, 2012):
This is a duplicate of issue 900.