This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: C++ warnings vs. errors
- From: Joe Buck <Joe dot Buck at synopsys dot COM>
- To: Volker Reichelt <v dot reichelt at netcologne dot de>
- Cc: gcc at gcc dot gnu dot org
- Date: Wed, 11 Jun 2008 13:23:28 -0700
- Subject: Re: C++ warnings vs. errors
- References: <tkrat.d318c4730b1542b2@netcologne.de>
On Wed, Jun 11, 2008 at 04:12:18PM +0200, Volker Reichelt wrote:
> * Scopes in for-loops:
>
> void foo()
> {
> for (int i=0; i<10; ++i) {}
> i = 0;
> }
>
> warn.cc: In function 'void foo()':
> warn.cc:4: warning: name lookup of 'i' changed for new ISO 'for' scoping
> warn.cc:3: warning: using obsolete binding at 'i'
>
> Btw, because the compiler tries to be smart to track new scoping and old
> scoping at once it rejects valid code, accepts invalid code and even
> generates wrong code in some cases (see PR10852).
That was originally there because, around the time the standard was
first adopted, there was a lot of old code that used the original
cfront scoping rule. But people have had a decade now to get their
code right. It might even be better to toss the support for the
alternative parsing entirely, so the compiler just reports the final
use of i as a reference to an undefined symbol.