Created attachment 4610 [details] testcase Perhaps this is a violation of the spec and clang is right to disallow it, however it does crop up in "real world" code so it *might* be better for this to be a warning rather than an error. Here is a small example of what I'm talking about p.s. As it happens the one use of this in the AVM code base is entirely frivolous and can easily be removed, but perhaps it affects other codebases... void foo() { union { char *m_a; int *m_b; }; // some code if(somecondition) { union { char *m_a; int *m_b; }; // some code } } Currently clang gives you the following error: union-bug.cpp:11:10: error: member of anonymous union redeclares 'm_a' char *m_a; ^ union-bug.cpp:5:9: note: previous declaration is here char *m_a;
This seems like a bogus error. Consider this case: typedef void *voidPtr; void f() { union { int **ctxPtr; void **voidPtr; }; } t.cpp:4:31: error: member of anonymous union redeclares 'voidPtr' union { int **ctxPtr; void **voidPtr; }; ^ t.cpp:1:15: note: previous declaration is here typedef void *voidPtr; ^
Fixed at r114641.