================
@@ -376,6 +376,7 @@ LANGOPT(ConstexprCallDepth, 32, 512, Benign,
         "maximum constexpr call depth")
 LANGOPT(ConstexprStepLimit, 32, 1048576, Benign,
         "maximum constexpr evaluation steps")
+LANGOPT(MaxTemplateForExpansions, 32, 256, Benign, "maximum template for 
expansions")
 LANGOPT(EnableNewConstInterp, 1, 0, Benign,
----------------
Sirraide wrote:

The main reason I introduced a limit is because if someone does this
```c++
void f() {
    int x[10000000];
    template for (auto y : x) {}
}
```
we basically just hang ‘for ever’ (I haven’t actually timed it, but it’s 
definitely longer than a miniute; I didn’t wait for it to terminate on its 
own). As I understand it, the purpose of similar limits (e.g. for constant 
evaluation steps) is to prevent us from just hanging if a user ends up writing 
code like this, and I believe this is a similar situation. I can definitely see 
this happening accidentally with destructuring and iterating expansion 
statements.

https://github.com/llvm/llvm-project/pull/165195
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to