https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85505
Bug ID: 85505 Summary: Code accepted despite a variable using the same name as a parameter Product: gcc Version: 8.0.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: abbeyj+gcc at gmail dot com Target Milestone: --- The following code is accepted by GCC although I believe it should not be. This happens on all versions and all platforms currently available on https://gcc.godbolt.org/ Test case: class C { public: ~C(); }; void Foo(int data) { switch (0) { case 0:; } C b; float data; } I would have expected an error here like: error: declaration of 'float data' shadows a parameter Note that you do get this error if you comment out (seemingly unrelated) lines from the test case. Shout out to https://embed.cs.utah.edu/creduce/ for providing the above reduced test case.