This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Incorrect declaration parsing in gcc 3.0.3?
- From: Andreas Schwab <schwab at suse dot de>
- To: "D. Towner" <towner at cs dot bris dot ac dot uk>
- Cc: gcc <gcc at gcc dot gnu dot org>
- Date: Thu, 11 Apr 2002 12:08:22 +0200
- Subject: Re: Incorrect declaration parsing in gcc 3.0.3?
- References: <Pine.GSO.4.33.0204111010370.21594-100000@tao>
"D. Towner" <towner@compsci.bristol.ac.uk> writes:
|> Hi all,
|>
|> I am using gcc 3.0.3, both as a base from which to port a new machine, and
|> as a native compiler for Linux Mandrake 8.0. I recently noticed the
|> following strange error. Consider:
|>
|> 1: int main() {
|> 2: int i;
|> 3: i = 0;
|> 4: int d; // Declaration in code body,
|> 5: d = 0;
|> 6: }
|>
|> gcc 2.96 flags the declaration on line 4 as an error, but gcc 3.0.3
|> ignores this, and generates what appears to be correct code (albeit with
|> a C++-like declaration)? Have the rules on declarations changed, or is gcc
|> 3.0.3 doing something wrong?
This is correct in C99, so gcc is obliged to accept it. If you want gcc
to only accept C89 code you should compile with --std=c89.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE GmbH, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."