This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/44715] Break in increment expression of "for" statement inconsistent with g++
- From: "joseph at codesourcery dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 29 Jun 2010 16:36:43 -0000
- Subject: [Bug c/44715] Break in increment expression of "for" statement inconsistent with g++
- References: <bug-44715-10727@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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