https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72707
Bug ID: 72707 Summary: [4.6/4.7/4.8/4.9/5/6/7 regression] local anonymous union member hides names in the same scope Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- In [class.union], all versions of the C++ standard starting with 1998 require that: The names of the members of an anonymous union shall be distinct from the names of any other entity in the scope in which the anonymous union is declared. The following invalid test case is accepted by G++, implying that G++ fails to conform to this requirement. The test case is rejected by Clang 3.8 and EDG eccp 4.11. Prior to version 4.6, GCC rejected this test case with error: declaration of ‘int x’ shadows a parameter This error was removed and the regression introduced in r159383. $ cat xyz.c && /build/gcc-71912/gcc/xgcc -B /build/gcc-71912/gcc -S -Wall -Wextra -Wpedantic -xc++ xyz.c void f (double &x) { union { int x; }; x = 0; } xyz.c: In function ‘void f(double&)’: xyz.c:1:17: warning: unused parameter ‘x’ [-Wunused-parameter] void f (double &x) ^