bug? for(int i=0;i<1;) vs while(true)

Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Sep 17 12:35:03 PDT 2015


On Thursday, 17 September 2015 at 19:32:16 UTC, ddos wrote:
> source\app.d(72): Warning: statement is not reachable

What's there? Anything after an endless loop is potentially 
unreachable and dub treats warnings as errors.

With the for loop, the compiler can't be as sure that it is 
endless because plain for loops often have their variable changed 
inside and the compiler just isn't smart enough to actually check 
for that too.


More information about the Digitalmars-d-learn mailing list