Hello,
with gcc-4.2.3, this does not compile:
typedef int foo;
int f(foo)
int foo;
{
return foo;
}
The error message is rather explicit ("old-style parameter declarations
in prototyped function definition"), which means that the compiler, when
encountering the "foo" on the second line, considered it to be a type
name, and not an argument name which would override the global type
definition within the function scope.
I understand, from a practical point of view, that doing otherwise would
mess the compiler (it would contradict the almost-LALR(1) property of
the C grammer). However, I cannot find in the C standard where such an
override is forbidden. Right now, it seems to me that the construction
is ambiguous.
Could someone shed some light on this ?
--Thomas Pornin
with gcc-4.2.3, this does not compile:
typedef int foo;
int f(foo)
int foo;
{
return foo;
}
The error message is rather explicit ("old-style parameter declarations
in prototyped function definition"), which means that the compiler, when
encountering the "foo" on the second line, considered it to be a type
name, and not an argument name which would override the global type
definition within the function scope.
I understand, from a practical point of view, that doing otherwise would
mess the compiler (it would contradict the almost-LALR(1) property of
the C grammer). However, I cannot find in the C standard where such an
override is forbidden. Right now, it seems to me that the construction
is ambiguous.
Could someone shed some light on this ?
--Thomas Pornin
Comment