Path: utzoo!attcan!ncrcan!scocan!ron From: ron@sco.COM (Ron Irvine) Newsgroups: comp.lang.c++ Subject: FORever Message-ID: <1990Sep27.150948.9109@sco.COM> Date: 27 Sep 90 19:09:48 GMT Reply-To: ron@sco.COM (Ron Irvine) Organization: SCO Canada, Inc. (formerly HCR Corporation) Lines: 26 BEWARE there is a major problem with C++'s "for" statement. main() { for (int i=10; i<13;) { for (int i=0; i<3; ++i) ; // stuff ++i; } } Cfront accepts this code and compiles without warning. The resulting code is totally unexpected! The program loops forever?!! I realize the problem is that cfront does not end the scope of the inners loop's "i" until the end of the outer loop, thus the "++i;" statement actually increments the inner loops "i" whos scope is the outer loop. And I did not "redeclare" "i" in the outer loop since the outer "i"'s scope is outside the outer loop. This is a bad joke for a language that is designed for the 90's. The scope of a variable in a "for-init-statement" MUST end at the end of the "for" statement. Lets change the definition of the language NOW before we inflict horrendous pain on C++ programmers.