www.digitalmars.com         C & C++   DMDScript  

c++.beta - [bug] dmc 8.46.2

reply arjan ask.me.to writes:
I think this is a bug:

01:template < class T > class list
02:{
03:   private :
04:      T           array [ 10 ];
05:
06:   public :
07:      void        erase ( T *, T* )       {}
08:};
09:
10:
11:template < class Tp > class  my_list : protected list < Tp >
12:{
13:   public :
14:      void        Erase ( Tp  *_i )        { erase ( _i, _i ); }
15:};
16:
17:
18:
19:int  main ()
20:{
21:   int  i = 0;
22:
23:
24:   my_list < int >   lst;
25:
26:   lst.Erase ( &i );
27:
28:   return ( 0 );
29:}

P:\apk\bugs>dmc tmplnm.cpp
tmplnm.cpp(14) : Error: undefined identifier 'erase'
--- errorlevel 1

using the -Ad flag makes the error disappear.
using Erase ( Tp  *_i ) { this -> erase ( _i, _i ); } also make the error
disappear.
I think the compiler should/must be able to figure out the base class has a
member function which exactly fits in here. 

I might be missing the obvious, than enlight me please.

Thanx,
Arjan Knepper
Jan 03 2006
parent reply "Walter Bright" <newshound digitalmars.com> writes:
<arjan ask.me.to> wrote in message news:dpev06$17s6$1 digitaldaemon.com...
 I might be missing the obvious, than enlight me please.
Welcome to the lovely world of funky name lookup rules for templates. Template classes don't look up names in base class templates. And no, it's not obvious at all.
Jan 03 2006
parent reply Arjan <arjan ask.me> writes:
Walter Bright wrote:
 <arjan ask.me.to> wrote in message news:dpev06$17s6$1 digitaldaemon.com...
 
I might be missing the obvious, than enlight me please.
Welcome to the lovely world of funky name lookup rules for templates. Template classes don't look up names in base class templates. And no, it's not obvious at all.
Your are probably right, but IIRC that was only the case for _non_ type dependant members. In this case the member is type dependant so shouldn't it be found? Other compilers seems to do the lookup as I expected. (I don't have the C++ template book from vandevoorde & josuttis around here to look it up) Thanx, Arjan
Jan 04 2006
parent "Walter Bright" <newshound digitalmars.com> writes:
"Arjan" <arjan ask.me> wrote in message 
news:dpg85l$2f7i$1 digitaldaemon.com...
 Walter Bright wrote:
 Welcome to the lovely world of funky name lookup rules for templates. 
 Template classes don't look up names in base class templates. And no, 
 it's not obvious at all.
Your are probably right, but IIRC that was only the case for _non_ type dependant members. In this case the member is type dependant so shouldn't it be found?
list<Tp>::erase is type-dependent. See C++98 14.6.2-2 and 14.6.2.1-1.
 Other compilers seems to do the lookup as I expected.
Comeau gets it right.
Jan 04 2006