Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
c++ - [bug] two-phase name lookup
The following test-case should print "OK" (see 14.6.2 (3)), but I get "FAIL" with DMC 8.44.6n: #include <stdio.h> void f() { printf("OK\n"); } template<class T> struct A { void f() { printf("FAIL\n"); } }; template<class T> struct B : A<T> { void g() { f(); } }; int main() { B<int> b; b.g(); return 0; } bye, Christof -- http://cmeerw.org mailto:cmeerw at web.de xmpp:cmeerw at cmeerw.org ...and what have you contributed to the Net? Aug 06 2005
This is taken care of in the new beta. Aug 20 2005
I am sure Christof is much more knowledgeable than myself but I have to ask: why not replace this with this template<class T> template<class T> struct B : A<T> struct B : A<T> { { void g() { f(); } void g() { ::f(); } // only modified line }; }; A<T> has a function f() and global namespace has a function f(). Using ::f() explicity calls the global function f() therefore removing the ambiguity. Is the original code really a compiler failure? (OK I didn't test it on DM because I am at work. But it did work an another compiler.) /r Jay Carlson In article <newscache$4w3tki$4t2$1 msgid.cmeerw.org>, Christof Meerwald says...The following test-case should print "OK" (see 14.6.2 (3)), but I get "FAIL" with DMC 8.44.6n: #include <stdio.h> void f() { printf("OK\n"); } template<class T> struct A { void f() { printf("FAIL\n"); } }; template<class T> struct B : A<T> { void g() { f(); } }; int main() { B<int> b; b.g(); return 0; } bye, Christof -- http://cmeerw.org mailto:cmeerw at web.de xmpp:cmeerw at cmeerw.org ...and what have you contributed to the Net? Aug 24 2005
<jay.a.carlson gmail.com> wrote in message news:dejfag$213l$1 digitaldaemon.com...I am sure Christof is much more knowledgeable than myself but I have to Aug 25 2005
|