Hello,
clang gave an error on a code that compiled with gcc so far. The reduced
test case is:
----8<----8<----8<----8<---
class V;
struct E
{
E(const V& v_);
char* c;
V* v;
int i;
};
class V
{
private:
union {
char* c;
struct {
V* v;
int i;
};
};
};
E::E(const V& v_) :
c(v_.c), // line 25
v(v_.v),
i(v_.i)
{
}
----8<----8<----8<----8<---
Tried with gcc 4.4, 4.5, 4.6, 4.7, 4.8, all gave the same error:
gcc-4.8 -c gccaccessbug.cpp -Wall -Wextra
gccaccessbug.cpp: In constructor ‘E::E(const V&)’:
gccaccessbug.cpp:16:9: error: ‘char* V::<anonymous union>::c’ is private
gccaccessbug.cpp:25:7: error: within this context
Line 25 is where E::c is initialized, V::c is private so the error is
due. However, V::v and V::i are also private, but no diagnostic is
given. If I comment out 'c(v_.c)', the source compiles w/o error.
Should I file a bug report? Checked BZ for 'access control', but found
nothing relevant, only bugs related to templated code.
Regards, Peter