------- Comment #5 from paolo dot carlini at oracle dot com 2010-02-15 14:02 ------- What I see right now is that Inc::f is called but &i != &counter. Instead, in the first test, that at line #53 of ref2.cc, Inc::operator() is called with &i == &counter, and everything is fine.
I also tried moving out of line the member functions at lines #540 and #570 of <functional>, and also Int::f, and nothing changes at -O2, still doesn't fail, thus it's the inlining of something earlier in the call chain which makes a difference, and where we have to chase the temporary, it looks like. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43075