This is the mail archive of the gcc@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]

Re: -std=c89 shouldn't allow post-statement declarations


On Tue, 22 Jul 2003, Joe Buck wrote:

> > As you know from the manual, -std=c89 means "accept standard code" while
> > -pedantic means "reject nonstandard code".
> 
> We could make this argument, but is it the most useful behavior for the
> user?  It seems Jamie was expecting "C89 but not fussy" because he was
> interested in writing portable C code.

There are three logical meanings - the present one, what "-std=c89
-pedantic" means, and what "-std=c89 -pedantic-errors" means.  I don't
think he wanted either of the latter, although they are more logical
(minimising the options required to get a conforming implementation) and
there are some more subtle cases where -pedantic is in fact at present
needed to accept standard code (i.e., it removes warnings).  Rejecting an
arbitrary set of nonconforming programs (possibly determined by what
features were in 2.95) is rather less logical.

> Ah: we disable one extension from C++ (the // comments), but we leave in
> the other C++-based extension (declarations anywhere).  This seems
> inconsistent.

// comments can cause valid C89 code to be wrongly compiled.  Mixed
declarations and code can't; they only add new programs that are accepted,
without affecting the semantics of any valid C89 program or causing such a
program to be rejected.  Likewise many C99 and traditional GNU extensions
that use new syntax.  We can always accept statement expressions.  We can
always accept designated initializers.  But -std=c89 disables the "inline"  
keyword - another feature in C++ and C99 - because C89 programs could use
"inline" as an ordinary identifier.

-- 
Joseph S. Myers
jsm@polyomino.org.uk


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