[Bug c++/85505] Code accepted despite a variable using the same name as a parameter
rguenth at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Apr 24 07:55:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85505
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |nathan at gcc dot gnu.org
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
clang reports instead
t.C:10:10: error: redefinition of 'data' with a different type: 'float' vs
'int'
float data;
^
t.C:5:14: note: previous definition is here
void Foo(int data) {
^
1 error generated.
GCC says (if you comment for example 'C b;'):
t.ii: In function ‘void Foo(int)’:
t.ii:10:11: error: declaration of ‘float data’ shadows a parameter
float data;
^~~~
note the testcase is also to be rejected when using int for the second
declaration and it is about re-defining, not about shadowing I believe.
More information about the Gcc-bugs
mailing list