Bug 99474 - gcc -std=c89 should not allow inline declarations (regression from gcc 2.96)
Summary: gcc -std=c89 should not allow inline declarations (regression from gcc 2.96)
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc3
Version: 9
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 2003-07-20 23:53 UTC by Jamie Zawinski
Modified: 2007-04-18 16:55 UTC (History)
0 users

Clone Of:
Last Closed: 2003-07-21 08:53:00 UTC

Attachments (Terms of Use)

Description Jamie Zawinski 2003-07-20 23:53:24 UTC
Description of problem:

In the C89 standard, declarations may not follow statements:

    int x = 1;

The above is legal in C++, and I believe it is legal in C99,
but it is not legal in C89.

In order to keep my code portable amongst various compilers
on various architectures, including non-gcc compilers, I want
the compiler to issue an error when it encounters any code that
is not legal in C89.

With gcc 2.96 20000731 (Red Hat Linux 7.2) I was able to do that
with these arguments:

  -std=c89 -U__STRICT_ANSI__

That disallowed // comments and post-statement declarations,
and all was good.

With gcc 3.2.2 20030222 (Red Hat Linux 9) this no longer works:
with those arguments, post-statement declarations are silently
allowed, resulting in un-flagged unportable code.

Please fix this -std=c89 to allow *only* those features that are
a part of the C89 standard.  (The -std=gnu89 arguement already
exists to indicate "C89 plus non-standard extensions.")

Version-Release number of selected component (if applicable):

How reproducible:

Comment 1 Jakub Jelinek 2003-07-21 07:35:39 UTC
Guess you missed -std=c89 -pedantic (or even -std=c89 -pedantic-errors) in
gcc command line switches documentation:
"To select this
standard in GCC, use one of the options `-ansi', `-std=c89' or
`-std=iso9899:1990'; to obtain all the diagnostics required by the
standard, you should also specify `-pedantic' (or `-pedantic-errors' if
you want them to be errors rather than warnings)."

Comment 2 Jamie Zawinski 2003-07-21 07:45:52 UTC
That's not the same thing.

gcc3 "-std=c89 -pedantic" produces a zillion more errors/warnings than
gcc2 "-std=c89" did.

I really just want the gcc2 behavior back.  Why do you think that's a
bad idea?

Comment 3 Jakub Jelinek 2003-07-21 08:53:00 UTC
I have no problems with the current behaviour, if you want to write standard
compliant code, -pedantic* is a must, if you don't, you accept there are some extensions
allowed or that you don't get diagnostic everywhere where required.
There is no -std=gnu89gcc29x mode which would be the language dialect
accepted by gcc 2.9x -std=gnu89.
If you want to argue about this, please do so either in gcc.gnu.org bugzilla
or on gcc@gcc.gnu.org mailing list. If it gets changed upstream we will
change accordinly of course.

Note You need to log in before you can comment on or make changes to this bug.