public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* template inheritance bug in gcc 3.4.3 ?
@ 2005-01-24 17:19 Петр Кравченко
  0 siblings, 0 replies; only message in thread
From: Петр Кравченко @ 2005-01-24 17:19 UTC (permalink / raw)
  To: gcc-bugs

[-- Attachment #1: Type: text/plain, Size: 2104 bytes --]

1. bash-2.05b$ gcc -v
Reading specs from /usr/lib/gcc/i486-pc-linux-gnu/3.4.3/specs
Configured with: /var/tmp/portage/gcc-3.4.3-r1/work/gcc-3.4.3/configure
--enable-version-specific-runtime-libs --prefix=/usr
--bindir=/usr/i486-pc-linux-gnu/gcc-bin/3.4.3
--includedir=/usr/lib/gcc/i486-pc-linux-gnu/3.4.3/include
--datadir=/usr/share/gcc-data/i486-pc-linux-gnu/3.4.3
--mandir=/usr/share/gcc-data/i486-pc-linux-gnu/3.4.3/man
--infodir=/usr/share/gcc-data/i486-pc-linux-gnu/3.4.3/info
--with-gxx-include-dir=/usr/lib/gcc/i486-pc-linux-gnu/3.4.3/include/g
++-v3 --host=i486-pc-linux-gnu --disable-altivec --enable-nls
--without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu
--with-system-zlib --disable-checking --disable-werror
--disable-libunwind-exceptions --enable-shared --enable-threads=posix
--disable-libgcj --enable-languages=c,c++,f77
Thread model: posix
gcc version 3.4.3 20041125 (Gentoo Linux 3.4.3-r1, ssp-3.4.3-0,
pie-8.7.7)

2. source file (1.cc):
template <class T> class C1 {
public:
  C1() {}
  virtual ~C1() {}
protected:
  T* m_prop;
};

template <class T> class C2 : public C1<T> {
public:
  C2() {}
  void A() { m_prop = (T*)0; }
  virtual ~C2() {}
};

int main() {
  C2<int> a;
  return 0;
}

3. 1.ii
# 1 "1.cc"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "1.cc"
template <class T> class C1 {
public:
  C1() {}
  virtual ~C1() {}
protected:
  T* m_prop;
};

template <class T> class C2 : public C1<T> {
public:
  C2() {}
  void A() { m_prop = (T*)0; }
  virtual ~C2() {}
};

int main() {
  C2<int> a;
  return 0;
}

4. compilation result:
bash-2.05b$ g++ --save-temps 1.cc 
1.cc: In member function `void C2<T>::A()':
1.cc:12: error: `m_prop' undeclared (first use this function)
1.cc:12: error: (Each undeclared identifier is reported only once for
each function it appears in.)

5. ??workaround?? if i use explicit scoping { C1<T>::m_prop = ... } all
is ok.

-- 
Кравченко Петр Геннадьевич
НПП "СпецСтрой Связь", НТЦ, разработчик
Тел. +7(8634)311562 доп 225
mailto: piterk@proton-sss.ru


[-- Attachment #2: Эта часть сообщения подписана цифровой подписью --]
[-- Type: application/pgp-signature, Size: 307 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-01-24 17:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-24 17:19 template inheritance bug in gcc 3.4.3 ? Петр Кравченко

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).