This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: G++ refuses to compile simple, looking good code
- From: niXman <i dot nixman at gmail dot com>
- To: Luchezar Belev <lukcho at gmail dot com>, gcc-help at gcc dot gnu dot org
- Date: Fri, 14 Jun 2013 13:34:55 +0400
- Subject: Re: G++ refuses to compile simple, looking good code
- References: <CAJtzQrxJWGjSnrOLqTBoPCgPsdECX2n=nZbJPRCP_Jik=_P1Zw at mail dot gmail dot com>
2013/6/14 Luchezar Belev:
> Hi,
> i'm not a c++/template guru and i can't decide if this is really a
> valid code or i have encountered a gcc bug:
>
> ------------------------------
> template <class T> struct A {
> void *p;
> };
> template <class T> struct B : A<T> {
> void *foo() { return p; }
> };
> ------------------------------
>
> g++ says "error: 'p' was not declared in this scope".
template <class T>
struct A {
void *p;
};
template <class T>
struct B : A<T> {
void *foo() { return A<T>::p; } // <<<<<<<<<<<<<<<<<<
};
int main() {
B<int> bi;
return bi.foo() != 0;
}
--
Regards,
niXman
___________________________________________________
Dual-target(32 & 64-bit) MinGW compilers for 32 and 64-bit Windows:
http://sourceforge.net/projects/mingwbuilds/
___________________________________________________
Another online IDE: http://liveworkspace.org/