http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47688
Summary: [C++0x] Segfault when assigning lambda to std::function variable Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: vitus...@gmail.com Created attachment 23301 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23301 Output of -save-temps Hello, g++ crashes while compiling following code (if it is of any use): #include <functional> int main() { std::function <void (int)> f = [] (int& x) // type mismatch on purpose { x += 3; }; } Command line: g++ -std=c++0x -Wall crash2.cpp Compiler crashes with following error: In file included from crash2.cpp:1:0: c:\gcc\bin\../lib/gcc/i686-pc-mingw32/4.6.0/../../../../include/c++/4.6.0/functional: In static member function 'static void std::_Function_handler<void(_ArgTypes ...), _Functor>::_M_invoke(const std::_Any_data&, _ArgTypes ...) [with _Functor = main()::<lambda(int&)>, _ArgTypes = {int}]': c:\gcc\bin\../lib/gcc/i686-pc-mingw32/4.6.0/../../../../include/c++/4.6.0/functional:2135:6: instantiated from 'std::function<_Res(_ArgTypes ...)>::function(_Functor, typename std::enable_if<(! std::is_integral<_Functor>::value), std::function<_Res(_ArgTypes ...)>::_Useless>::type) [with _Functor = main()::<lambda(int&)>, _Res = void, _ArgTypes = {int}, typename std::enable_if<(! std::is_integral<_Functor>::value), std::function<_Res(_ArgTypes ...)>::_Useless>::type = std::function<void(int)>::_Useless]' crash2.cpp:8:2: instantiated from here c:\gcc\bin\../lib/gcc/i686-pc-mingw32/4.6.0/../../../../include/c++/4.6.0/functional:1765:9: error: no match for call to '(main()::<lambda(int&)>) (int)' crash2.cpp:5:34: note: candidates are: c:\gcc\bin\../lib/gcc/i686-pc-mingw32/4.6.0/../../../../include/c++/4.6.0/functional:1765:9: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. Using GCC 4.6.0 20110205 on Windows Vista (32bit). Output of g++ -v: Built by Equation Solution <http://www.Equation.com>. Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=c:/gcc/bin/../libexec/gcc/i686-pc-mingw32/4.6.0/lto-wrapper.exe Target: i686-pc-mingw32 Configured with: ../gcc-4.6-20110205-mingw/configure --host=i686-pc-mingw32 --build=x86_64-unknown-linux-gnu --target=i686-pc-mingw32 --prefix=/home/gfortran/gcc-home/binary/mingw32/native/x86_32/gcc/4.6-20110205 --with-lto-plugin --with-gcc --with-gnu-ld --with-gnu-as --with-host-libstdcxx='-lstdc++ -lsupc++ -lm' --with-ppl=/home/gfortran/gcc-home/binary/mingw32/native/x86_32/ppl --with-cloog=/home/gfortran/gcc-home/binary/mingw32/native/x86_32/cloog --with-gmp=/home/gfortran/gcc-home/binary/mingw32/native/x86_32/gmp --with-mpfr=/home/gfortran/gcc-home/binary/mingw32/native/x86_32/mpfr --with-mpc=/home/gfortran/gcc-home/binary/mingw32/native/x86_32/mpc --with-sysroot=/home/gfortran/gcc-home/binary/mingw32/cross/x86_32/gcc/4.6-20110205 --enable-languages=c,c++,fortran --enable-libgomp --enable-threads=win32 --enable-lto --enable-static --enable-cloog-backend=ppl --disable-shared --disable-nls --disable-tls --disable-win32-registry Thread model: win32 gcc version 4.6.0 20110205 (experimental) (GCC) Output of g++ -std=c++0x crash2.cpp -save-temps is in attachment. Thanks for your time, Vít Šefl