This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Failed access check
- From: "Peter A. Felvegi" <petschy at praire-chicken dot com>
- To: gcc at gcc dot gnu dot org
- Date: Mon, 23 Apr 2012 14:54:33 +0200
- Subject: Failed access check
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