[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#492079: [g++-4.3] following code don't compile, g++ can't see inherited variable



Package: g++-4.3
Version: 4.3.1-2
Severity: normal

--- Please enter the report below this line. ---

The following code can't be compiled, workaround is to use "this" pointer:
//////////////////////////////////////////
class A {
protected:
    int len;
};

template <int N>
class B : public A {
protected:
    char buf[N];
};

template <int N>
class C : public B<N> {
public:
    int do_workaround_len() { return this->len; }
    int do_someting_len() { return len; }
};

int main() {
//    C<500> c;
    return 0;
}

/////////////////////////////////////////
g++ test.cpp

test.cpp: In member function ‘int C<N>::do_someting_len()’:
test.cpp:17: error: ‘len’ was not declared in this scope

same result using g++ version 4.1, 4.2, 4.3


--- System information. ---
Architecture: i386
Kernel:       Linux 2.6.25-2-686

Debian Release: lenny/sid
   90 unstable        www.debian-multimedia.org 
   90 unstable        ftp.debian-unofficial.org 
   90 unstable        ftp.bg.debian.org 
   90 unstable        apt.byteme.org.uk 
   80 experimental    ftp.bg.debian.org 
  500 testing         www.debian-multimedia.org 
  500 testing         security.debian.org 
  500 testing         ftp.debian-unofficial.org 
  500 testing         ftp.bg.debian.org 
  500 any             apt.jenslody.de 

--- Package information. ---
Depends                  (Version) | Installed
==================================-+-============
gcc-4.3-base           (= 4.3.1-2) | 4.3.1-2
gcc-4.3                (= 4.3.1-2) | 4.3.1-2
libstdc++6-4.3-dev     (= 4.3.1-2) | 4.3.1-2
libc6                   (>= 2.7-1) | 2.7-10
libgmp3c2                          | 2:4.2.2+dfsg-3
libmpfr1ldbl                       | 2.3.1.dfsg.1-2





Reply to: