Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
August 06, 2005 [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? |
August 20, 2005 Re: [bug] two-phase name lookup | ||||
---|---|---|---|---|
| ||||
Posted in reply to Christof Meerwald | This is taken care of in the new beta. |
August 25, 2005 Re: [bug] two-phase name lookup | ||||
---|---|---|---|---|
| ||||
Posted in reply to Christof Meerwald | 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? jay.a.carlson@gmail.com |
August 25, 2005 Re: [bug] two-phase name lookup | ||||
---|---|---|---|---|
| ||||
Posted in reply to jay.a.carlson | <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 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? Christof writes code to test compiler features and standards conformance, so the bug reports he posts are usually not the result of some bug he's trying to work around. He's got a nice web page up comparing standards conformance of various C++ compilers: http:///cmeerw.org. I owe Christof a big debt of gratitude as he's the one who figured out everything that was going wrong with DMC++'s early template implementation and distilled them all down to short & sweet bug reports. |
April 28, 2008 Re: [bug] two-phase name lookup | ||||
---|---|---|---|---|
| ||||
Posted in reply to Christof Meerwald | try this--- #include <stdio.h> #include <iostream> #include <conio.h> using namespace std; int main(); 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(); getchar(); return 0; } |
Copyright © 1999-2021 by the D Language Foundation