#include <vector> struct Int { explicit Int(int); }; Int intfunc(Int, Int); template<typename FwdIt, typename Func, typename T> auto foldl(FwdIt first, FwdIt last, Func f, T initial) -> decltype(f(initial, *first)) { for(; first != last; ++first) { initial = f(initial, *first); } return initial; } // instantiate template to check compilation void instantiate() { std::vector<Int> v; Int x3 = foldl(v.begin(), v.end(), intfunc, Int(0)); Int x4 = foldl(v.cbegin(), v.cend(), intfunc, Int(0)); } When I compile this on VC++2010, I get warning: Warning 1 warning C4172: returning address of local variable or temporary c:\users\jensa\desktop\vs2010bug\foldl\foldl\foldl.cpp 18 Warning 2 warning C4172: returning address of local variable or temporary c:\users\jensa\desktop\vs2010bug\foldl\foldl\foldl.cpp 18
Visual Studio/Team Foundation Server/.NET Framework Tooling version
Steps to reproduce
Product Language
Operating System
Operating System Language
Actual results
Expected results
Please wait...