https://issues.dlang.org/show_bug.cgi?id=14419
--- Comment #2 from Kenji Hara <[email protected]> --- (In reply to Iain Buclaw from comment #0) > This was noticed and raised in GDC Bugzilla #178 because of a typo in the > code. > > http://bugzilla.gdcproject.org/show_bug.cgi?id=178 > > > What it boils down to is this: > --- > int foo() { while (true) { } return 1; } > enum bar = foo; // User meant to type '&foo' > --- > > Perfectly valid code causing an infinite loop in CTFE. Obviously this is a > bug vs. feature argument, but infinite loop detection should really be a > feature of CTFE to avoid accidental build bugs from occurring. How to do it for a complex code? int foo(int n = 0) { while (true) { ++n; if (n > 1_000_000) break; } return 1; } enum bar = foo; // User meant to type '&foo' Using while(true) for the limited loop is usual. And limiting loop repetition to arbitrary count is problematic (a million repetition is too big?). The idea sounds good, but implementing it would be difficult. --
