public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/9419: inherited member in template doesnt work
@ 2003-01-23 16:16 rassahah
  0 siblings, 0 replies; 2+ messages in thread
From: rassahah @ 2003-01-23 16:16 UTC (permalink / raw)
  To: gcc-gnats


>Number:         9419
>Category:       c++
>Synopsis:       inherited member in template doesnt work
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 23 16:16:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Rasmus Hahn
>Release:        gcc version 3.4 20030123
>Organization:
>Environment:
$ g++ -v
Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.4/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-threads --enable-languages=c,c++,objc
Thread model: posix
gcc version 3.4 20030123 (experimental)
>Description:
g++ does not find inherited member in template class. if specifiing member with explicitely with
`this->' it works. This bug seems new in this version of g++; the version from a few weeks ago
worked.
output from how-to-repeat:
$ g++ x.cc
x.cc: In member function `void B<X>::foo()':
x.cc:9: error: `a' has not been declared
$ 
>How-To-Repeat:
template <class X>
struct A {
  int a;
};

template <class X>
struct B :public A <X> {
  void foo () {
    a = 3; // with `this->a = 3' it works
  }
};
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: c++/9419: inherited member in template doesnt work
@ 2003-01-23 16:21 bangerth
  0 siblings, 0 replies; 2+ messages in thread
From: bangerth @ 2003-01-23 16:21 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, rassahah

Synopsis: inherited member in template doesnt work

State-Changed-From-To: open->closed
State-Changed-By: bangerth
State-Changed-When: Thu Jan 23 16:21:19 2003
State-Changed-Why:
    That's how C++ is supposed to work. Name loopup inside
    templates does not look into base classes, and since your
    variable's name is not obviously template type dependent,
    you need to tell the compiler that it depends on the
    template type, for example by using this->

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9419


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-01-23 16:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-23 16:16 c++/9419: inherited member in template doesnt work rassahah
2003-01-23 16:21 bangerth

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).