http://d.puremagic.com/issues/show_bug.cgi?id=2678
Summary: for loops are already assumed to terminate Product: D Version: unspecified Platform: PC OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzi...@digitalmars.com ReportedBy: and...@metalanguage.com Consider this code compiled with -w: int main() { int i; for (;; ++i) { if (i == 10) return 0; } i += 100; } This loop never reaches its end. However the compiler does not detect that and spuriously asks for a return at the end of the function. Worse, if there is some unreachable code following the loop, it does not recognize that. All loops that (a) have no termination condition or a nonzero compile-time-constant termination condition, and (b) do not embed any "break" statement - should be understood as loops that do not fall through. Before anyone brings up Turing completeness: I said "nonzero compile-time-constant termination condition". --