[cfe-dev] Accessing private members through typedefs
John McCall
rjmccall at apple.com
Fri Apr 30 19:17:27 PDT 2010
On Apr 30, 2010, at 6:49 PM, John Thompson wrote:
> I have the following:
>
> template <class TYPE> class test;
> typedef test<int> testClass;
> typedef testClass& refTestClass;
> template <typename TYPE> class test
> {
> public:
> test(refTestClass other);
> private:
> int member;
> };
> template <typename TYPE>
> inline test<TYPE>::test(refTestClass other) {
> member = other.member;
> }
> C:\Sony\Clang\exp>clang -cc1 priv.cpp
> priv.cpp:15:17: error: 'member' is a private member of 'test<int>'
> member = other.member;
> ^
> priv.cpp:10:6: note: declared private here
> int member;
>
> Is this a bug or legitimate behavior?
It's a bug. There is one valid instantiation of this template, at TYPE=int, so we can't diagnose.
The bug has nothing to do with typedefs. Reduction:
template <class T> class A {
int foo;
int getFoo(A<int> &a) {
return a.foo;
}
};
> Sorry to bug you with these. Basically I'm running Clang over a very large program written by someone else and compiled with gcc. Is this the appropriate place for this, or should I just file bugs and let someone else respond as needed?
Bugs are probably more appropriate. Please file this one.
John.
More information about the cfe-dev
mailing list