This is the mail archive of the gcc-bugs@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]

[Bug c++/85505] Code accepted despite a variable using the same name as a parameter


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.

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