This compiles and runs: void main() { int x = 2; for (while (false) x = 2; x != 2; ) {} } along with some other similarly odd constructs.
That's been known for some time. It's done that way to allow this to work: for(int a = 5; a < 10; a++) {} ----[statment] I think the best "fix" would be to switch from a statement, to allowing an expression or declaration. OTOH I'm fine with it as it is as it doesn't cause any known problems with "reasonable" code.
(In reply to comment #1) > That's been known for some time. It's done that way to allow this to work: > > for(int a = 5; a < 10; a++) {} > ----[statment] > > I think the best "fix" would be to switch from a statement, to allowing an > expression or declaration. That's how I thought it was defined - but it turns out ForStatement: for ( Initialize Test ; Increment ) ScopeStatement Initialize: ; NoScopeNonEmptyStatement so I was wrong about this being accepts-invalid.
I'll mark it as invalid, then.
Cool, this is going to make for some interesting plays :o).