Infinite compilation with templates

后端 未结 4 1155
小鲜肉
小鲜肉 2021-01-05 21:07

This question is just out of curiosity. In recursive templates if we forget to put one particular specialization, then compiler will do large number of iterations and then s

4条回答
  •  长情又很酷
    2021-01-05 21:47

    Getting the parser into an infinite loop using template is not new.

    // Stresses the compiler infinitely
    // from: http://www.fefe.de/c++/c%2b%2b-talk.pdf
    template struct Loop { Loop operator->(); };
    Loop i, j = i->hooray;
    

提交回复
热议问题