This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Confusing about the accessibility of the base class


On Wed, May 11, 2011 at 6:10 PM, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
> On 11 May 2011 11:04, zhang qingshan wrote:
>> Hi, guys,
>>
>> I test the following testcase with GCC 4.6
>>
>> struct A {
>> private:
>> ? struct Patch {};
>> };
>>
>> #ifdef TMPL
>> template <int x>
>> #endif
>> struct X : private A
>> {
>> ? void f () {
>> ? ? ?typedef A::Patch Patch;
>> ? }
>> };
>> int main()
>> {
>> #ifdef TMPL
>> ?X<1> d;
>> #else
>> ?X d;
>> #endif
>> ?d.f();
>> }
>>
>> If TMPL is not defined, get the error message:
>>
>> /data/a.cpp: In member function 'void X::f()':
>> /data/a.cpp:3:11: error: 'struct A::Patch' is private
>> /data/a.cpp:12:24: error: within this context
>>
>> which makes sense, as struct Patch is the private member of struct A.
>> But if TMPL is defined, GCC compiles it clean. This confuses me.
>>
>
> It's a bug.
>
> Unfortunately there are several bugs related to access-checking in
> templates:
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40901
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48078
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47346
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45917
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45011
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41437
>
Thanks for your information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]