[RFC]: allowing c99 for-loop scope in gnu89?

Kaveh R. Ghazi ghazi@caip.rutgers.edu
Thu Jun 20 09:53:00 GMT 2002


 > From: "Joseph S. Myers" <jsm28@cam.ac.uk>
 > 
 > On Wed, 19 Jun 2002, Kaveh R. Ghazi wrote:
 > 
 > > We allow using many c99 features in gnu89.  How about for-loop scopes
 > > and declaring a loop iteration variable in the initialization?  E.g.:
 > > 
 > >  >   for (int i=0; i<4; i++)
 > >  >     printf ("i=%d\n", i);
 > > 
 > > We seem to go out of our way to stop people from doing this in
 > > check_for_loop_decls.
 > 
 > I believe checking there is better than giving a confusing error when
 > there are two loops in the same scope with the same variable.  I don't
 > think the scopes should be enabled by default in C89 mode (straight cases
 > like this of quiet changes in the meaning of code valid under both
 > standards, albeit fairly obscure code, are ideal cases where the
 > difference should be based on flag_isoc99 and no other flag).  In general
 > uses of flag_iso and allied flags are a mistake and should be avoided
 > except for well-defined long-established cases; as far as possible we
 > should be conforming to the base standard by default, c89 should mean much
 > the same as gnu89 and c99 as gnu99, extensions consistent with the base
 > standard should be enabled and -pedantic should add (but not take away)  
 > warnings.

I'm not sure whether you're for or against my proposal, but I'm
suggesting we relax the check in check_for_loop_decls. to a pedwarn
instead of a hard error.

A quick grep shows this is no different to how we handle other c99
features, for example "long long", complex types, variable sized
arrays and flexible array members.

		--Kaveh
--
Kaveh R. Ghazi			Director of Systems Architecture
ghazi@caip.rutgers.edu		Qwest Solutions



More information about the Gcc mailing list