[RFC]: allowing c99 for-loop scope in gnu89?
Joseph S. Myers
jsm28@cam.ac.uk
Wed Jun 19 23:30:00 GMT 2002
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.
--
Joseph S. Myers
jsm28@cam.ac.uk
More information about the Gcc
mailing list