Created attachment 29075 [details] preprocessed source This appears to be similar but not identical to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54604. Repro case: #include <map> #include <functional> using namespace std; struct tData { double a; }; template<class DataType> class MapWrap { public: void Insert(const int& p, const DataType& data) { m_[p] = data; } function<void(const DataType&)> CreateInserter(function<int(const DataType&)> data_to_int) { return [this, data_to_int](const DataType& data) { Insert(data_to_int(data), data); }; } private: map<int, DataType> m_; }; int main(int argc, char **argv) { MapWrap<tData> m; auto fn = m.CreateInserter([](const tData& d) { return static_cast<int>(d.a); }); fn({12}); }
I forgot to mention that adding "this->" to the Insert() call causes compilation to succeed.
Version information: $ g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 4.7.2-4' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --with-arch-32=i586 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.7.2 (Debian 4.7.2-4)
Dup. *** This bug has been marked as a duplicate of bug 53137 ***