The one liner void f( int fred, char * fred); is IMHO illegal code because fred is the name of two parameters. I couldn't get gcc332 to find the bug in this code. This is salted down from real code in Fedora Core 1.
Confirmed with mainline/3.4 branch. C frontend properly rejects this, so this is not a duplicate of PR13728.
*** Bug 17786 has been marked as a duplicate of this bug. ***
As mentioned in PR 17786 by Nathan: correct. there is a related bug in that we fail to compile things like void foo (int x, int ary[sizeof(x)]);
(In reply to comment #0) > The one liner > > void f( int fred, char * fred); > > is IMHO illegal code because fred is the name of two parameters. I just checked gcc 4.2 and it is broken there as well. Even adding flags -Wall -ansi -pedantic doesn't help
Based on 8.3.5/8 and the example from 8.3.6/9 which reads int f(int a, int b = a); I think this bug is invalid and function declarations with duplicate parameter names are not invalid.
it might not be invalid, but its certainly worth a diagnostic IMHO
(In reply to comment #5) > Based on 8.3.5/8 and the example from 8.3.6/9 which reads > > int f(int a, int b = a); > > I think this bug is invalid and function declarations with duplicate parameter > names are not invalid. I don't understand how the line of code you mention helps demonstrate your logic. Two parameters are declared, one called a and one called b. In the standard, the end of paragraph 8.3.5.7 says If a parameter name is present in a function declaration that is not a definition, it cannot be used outside of the parameter-declaration-clause since it goes out of scope at the end of the function declarator So it implies that a new scope is entered at the ( and exited at the ). But we already know that a name can't be reused at the same scope [ except for function overloading, but that's different]. QED.
This is fixed in current mainline GCC (as per http://gcc.gnu.org/gcc-4.3/porting_to.html).
Apparently fixed.