http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49734
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-07-13 14:29:35 UTC --- You probably want to use the return value: add = std::for_each(l, l + 5, add); Although for this specific case you could #include <numeric> and use std::accumulate int acc = std::accumulate(c, c + 5, 0);