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: Incorrect declaration parsing in gcc 3.0.3?


"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."


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