http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46056
--- Comment #6 from Rodrigo Rivas <rodrigorivascosta at gmail dot com> 2010-10-20 08:56:30 UTC --- Ok, thank you for the report... It looks like the range-for temporary completely ignore destructors. Also, if the range is a temporary it gets destructed quite early, instead of being kept alive because of the implicit reference. for (auto x : temp() ) //the temporary is destroyed here { //... } //instead of here It shouldn't be too difficult to patch, though, so I'll try and have a patch in a while...