I believe you're wrong, Sane.
#include <iostream>
#include <boost/foreach.hpp>
int main() {
const int numbs[] = { 1, 2, 3, 4, 5 };
BOOST_FOREACH ( int n, numbs ) {
std::cout << n << std::endl;
}
}
$ valgrind ./example
==11578== Memcheck, a memory error detector.
==11578== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al.
==11578== Using LibVEX rev 1804, a library for dynamic binary translation.
==11578== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
==11578== Using valgrind-3.3.0, a dynamic binary instrumentation framework.
==11578== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al.
==11578== For more details, rerun with: -v
==11578==
1
2
3
4
5
==11578==
==11578== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 19 from 1)
==11578== malloc/free: in use at exit: 0 bytes in 0 blocks.
==11578== malloc/free: 0 allocs, 0 frees, 0 bytes allocated.
==11578== For counts of detected errors, rerun with: -v
==11578== All heap blocks were freed -- no leaks are possible.
It is able to do this was some automagic templates of some kind.
I am also unable to reproduce the original bug when I test the specific conditions in a seperate file and compilation. I'm guessing the bug (if it exists) only occurs when very specific conditions are true.