This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/44715] Break in increment expression of "for" statement inconsistent with g++



------- Comment #1 from joseph at codesourcery dot com  2010-06-29 16:36 -------
Subject: Re:   New: Break in increment expression of "for"
 statement inconsistent with g++

On Tue, 29 Jun 2010, doug dot gregor at gmail dot com wrote:

> g++ seems to have the right behavior here, and in any case g++ can't really be
> changed now: Qt's foreach macro depends on having "break" bind to the inner for
> loop.

Yes, the inconsistency should be fixed, but for both C and C++ I get 
"error: break statement not within loop or switch" if I only have one loop 
rather than nested loops, and break binding to the inner loop seems 
inconsistent with that error.  The C standard specifically says that 
continue and break statements must appear in a loop body (or switch body, 
in the case of break); if you make break bind to the inner loop, you 
should also not have that error in the single loop case (the rule should 
change to allow additional positions in the loop outside its body).

Whatever is done needs clearly defining and documenting (with testcases) 
for both break and continue, and including all relevant places in for, 
while, do-while and switch statements (I do not make a claim here as to 
exactly which places should allow break and so bind to the inner 
construct, and which should not and so bind to the outer construct if 
any).


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44715


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]