This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/85505] Code accepted despite a variable using the same name as a parameter
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 24 Apr 2018 07:55:43 +0000
- Subject: [Bug c++/85505] Code accepted despite a variable using the same name as a parameter
- Auto-submitted: auto-generated
- References: <bug-85505-4@http.gcc.gnu.org/bugzilla/>
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.