This code (in includes needed) ICEs with GCC 4.5 20091112 template<typename F> decltype(F()) run(F f) { return f(); }
int main() { auto l = []() { return 5; }; run(l); } Compiler output: $ g++-4.5-20091112 -std=c++0x decl.cpp -o decl decl.cpp: In function 'int main()': decl.cpp:14:9: error: no matching function for call to 'main()::<lambda()>::__lambda0()' decl.cpp:12:11: note: candidates are: main()::<lambda()>::<lambda>(const main()::<lambda()>&) decl.cpp:12:11: note: main()::<lambda()>::<lambda>(main()::<lambda()>&&) decl.cpp:14:9: internal compiler error: tree check: expected aggr_init_expr, have error_mark in build_value_init, at cp/init.c:319 Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. -- Summary: [C++0x] ICE on invalid with "tree check: expected aggr_init_expr, have error_mark in build_value_init" Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: lloyd at randombit dot net GCC build triplet: x86_64-unknown-linux-gnu GCC host triplet: x86_64-unknown-linux-gnu GCC target triplet: x86_64-unknown-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42083