Bug 99474 - gcc -std=c89 should not allow inline declarations (regression from gcc 2.96)
gcc -std=c89 should not allow inline declarations (regression from gcc 2.96)
Product: Red Hat Linux
Classification: Retired
Component: gcc3 (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Depends On:
  Show dependency treegraph
Reported: 2003-07-20 19:53 EDT by Jamie Zawinski
Modified: 2007-04-18 12:55 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2003-07-21 04:53:00 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Jamie Zawinski 2003-07-20 19:53:24 EDT
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 03:35:39 EDT
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 03:45:52 EDT
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 04:53:00 EDT
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.