こわいはなし
template <typename ...Args> void f(Args... args){ [args...](){ }(); }
g++-4.5 -std=c++0x に投げ込むと
capture_pack.cpp: In function ‘void f(Args ...)’: capture_pack.cpp:3:8: error: expected ‘,’ before ‘...’ token capture_pack.cpp:3:8: error: expected identifier before ‘...’ token capture_pack.cpp:3:11: error: parameter packs not expanded with ‘...’: capture_pack.cpp:3:11: note: ‘args’
あと、
int main(){ f(0); }
を追加してあげると
capture_pack.cpp: In function ‘void f(Args ...)’: capture_pack.cpp:3:8: error: expected ‘,’ before ‘...’ token capture_pack.cpp:3:8: error: expected identifier before ‘...’ token capture_pack.cpp:3:11: error: parameter packs not expanded with ‘...’: capture_pack.cpp:3:11: note: ‘args’ capture_pack.cpp: In function ‘void f(Args ...) [with Args = {int}]’: capture_pack.cpp:7:6: instantiated from here capture_pack.cpp:3:3: error: using invalid field ‘f(Args ...)::<lambda()>::__args’ capture_pack.cpp:3:3: internal compiler error: tree check: expected field_decl, have error_mark in build_lambda_object, at cp/semantics.c:5409 完全なバグ報告を送って下さい。 適切ならばプリプロセス後のソースをつけてください。 <http://gcc.gnu.org/bugs.html> を見れば方法が書いてあります。
と言われる。