[prev in list] [next in list] [prev in thread] [next in thread]
List: gcc-bugs
Subject: c++/3009: Wrong name lookup in template
From: zhegulev () sigma ! ispras ! ru
Date: 2001-05-31 0:04:08
[Download RAW message or body]
>Number: 3009
>Category: c++
>Synopsis: Wrong name lookup in template
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed May 30 17:06:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: zhegulev@sigma.ispras.ru
>Release: 2.95.3
>Organization:
>Environment:
>Description:
According to 14.6.2.4 of C++ Standard:
"If a base class is a dependent type, a member of that
class cannot hide a name declared within a template, or a
name from the template's eclosing scopes."
#include <iostream.h>
class B{
public:
void foo(){cout << "B::foo"<<endl;}
};
void foo()
{ cout << "::foo()"<<endl;}
template <class T>
class C :public T
{
public:
void caller(){foo();}
};
int main()
{
C<B> c;
c.caller();
return 0;
}
That example should print
::foo()
But it prints
B::foo
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="template16.cc"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="template16.cc"
I2luY2x1ZGUgPGlvc3RyZWFtLmg+CgpjbGFzcyBCewogcHVibGljOgogICB2b2lkIGZvbygpe2Nv
dXQgPDwgIkI6OmZvbyI8PGVuZGw7fQp9OwoKdm9pZCBmb28oKQp7IGNvdXQgPDwgIjo6Zm9vKCki
PDxlbmRsO30KCnRlbXBsYXRlIDxjbGFzcyBUPgpjbGFzcyBDIDpwdWJsaWMgVAp7CiBwdWJsaWM6
CiAgIHZvaWQgY2FsbGVyKCl7Zm9vKCk7fQp9OwoKCmludCBtYWluKCkKewogIEM8Qj4gYzsKICBj
LmNhbGxlcigpOwogIHJldHVybiAwOwp9Cg==
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic