https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83290
Bug ID: 83290 Summary: Expressions in anonymous unions inside class templates can't reference the union's members Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: abigail.buccaneer at gmail dot com Target Milestone: --- The following code compiles fine (with -std=c++14): struct A { union { int x; char y[sizeof(x)]; decltype(x) z; static_assert(sizeof(y) == sizeof(z), ""); }; }; But fails when the struct is replaced with a struct template and instantiated as follows: template <typename> struct T { union { int x; char y[sizeof(x)]; decltype(x) z; static_assert(sizeof(y) == sizeof(z), ""); }; }; template struct T<void>; The errors all say essentially the same thing: <source>:13:23: error: 'int T<void>::<unnamed union>::x' is inaccessible within this context char y[sizeof(x)]; ~^~