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++ - Another namespace bug
Here is another one: namespace A { struct C { C(int i) { } }; namespace B { template<class T> struct D { D() { C c(3); // Error: undefined identifier 'C' } }; } } int main() { A::B::D<int> d; return 0; } bye, Christof -- http://cmeerw.org JID: cmeerw jabber.at mailto cmeerw at web.de Dec 05 2002
In article <asnd0i$2jn0$1 digitaldaemon.com>, Christof Meerwald says...Here is another one: Dec 05 2002
Another one: namespace ns { struct A {}; template <class T> struct B { }; template<> struct B<A> { typedef A iterator_category; // Error: ';' expected following declaration of struct member }; } int main() { ns::B<ns::A> i; return 0; } bye, Christof -- http://cmeerw.org JID: cmeerw jabber.at mailto cmeerw at web.de ...and what have you contributed to the Net? Dec 05 2002
And another one: namespace ns { template<class T> struct A { static void f() { } }; template<class T> struct B { void f() { A<T>::f(); // Error: 'ns::A<>::f' previously declared as something else // It was declared as: void C func() // It is now declared: int C func() } }; } int main() { ns::B<int> b; b.f(); return 0; } bye, Christof -- http://cmeerw.org JID: cmeerw jabber.at mailto cmeerw at web.de ...and what have you contributed to the Net? Dec 06 2002
Another one: namespace ns { template<class T> struct A { void f(); }; template<class T> void A<T>::f() // Error: 'A' is not a class template { } } int main() { ns::A<int> a; a.f(); return 0; } bye, Christof -- http://cmeerw.org JID: cmeerw jabber.at mailto cmeerw at web.de ...and what have you contributed to the Net? Dec 06 2002
Another one: namespace ns { struct A { A() { } }; struct B : public ns::A { B() : ns::A() // Error: 'ns' is not a member of struct 'ns::B' { } }; } int main() { return 0; } bye, Christof -- http://cmeerw.org JID: cmeerw jabber.at mailto cmeerw at web.de ...and what have you contributed to the Net? Dec 06 2002
template<class T> struct A { }; namespace ns { template<class T> struct A // Error: 'A' is already defined { }; } int main() { A<int> a; ns::A<int> ns_a; return 0; } bye, Christof -- http://cmeerw.org JID: cmeerw jabber.at mailto cmeerw at web.de ...and what have you contributed to the Net? Dec 07 2002
template<class T> struct A { }; namespace ns { using ::A; } int main() { ns::A<int> a; // Error: '<' expected following 'A' return 0; } bye, Christof -- http://cmeerw.org JID: cmeerw jabber.at mailto cmeerw at web.de ...and what have you contributed to the Net? Dec 07 2002
namespace ns1 { template<class T> struct A { A() { } // Error: namespace 'ns2' does not enclose member '?0' of namespace 'ns1' }; } namespace ns2 { void f() { ns1::A<int> a; } } int main() { ns2::f(); return 0; } bye, Christof -- http://cmeerw.org JID: cmeerw jabber.at mailto cmeerw at web.de ...and what have you contributed to the Net? Dec 08 2002
In article <at0k4t$hb5$1 digitaldaemon.com>, Christof Meerwald says...namespace ns1 { template<class T> struct A { A() { } // Error: namespace 'ns2' does not enclose member '?0' of namespace 'ns1' Dec 09 2002
In article <at0k4t$hb5$1 digitaldaemon.com>, Christof Meerwald says...namespace ns1 { template<class T> struct A { A() { } // Error: namespace 'ns2' does not enclose member '?0' of namespace 'ns1' Dec 09 2002
namespace ns { template<class T> struct A { }; } using ns::A; struct B : public A<int> // Error: 'A' is not a struct or a class { }; int main() { B b; return 0; } bye, Christof -- http://cmeerw.org JID: cmeerw jabber.at mailto cmeerw at web.de ...and what have you contributed to the Net? Dec 09 2002
namespace ns1 { struct A { static int value; }; int A::value = 0; } namespace ns2 { struct A { int f() { return ns1::A::value; // Error: 'A' must be a public base class of 'A' } }; } int main() { ns2::A a; return a.f(); } bye, Christof -- http://cmeerw.org JID: cmeerw jabber.at mailto cmeerw at web.de ...and what have you contributed to the Net? Dec 09 2002
namespace ns { template<class T> struct A { }; typedef A<char> B; } using ns::B; struct C : public B // Error: undefined identifier 'B' { }; int main() { C c; return 0; } bye, Christof -- http://cmeerw.org JID: cmeerw jabber.at mailto cmeerw at web.de ...and what have you contributed to the Net? Dec 11 2002
namespace ns { struct A { void f(); }; struct B { }; } void ns::A::f() { B b; // Error: undefined identifier 'B' } int main() { ns::A a; return 0; } (see 3.4.1 Unqualified name lookup [basic.lookup.unqual], paragraph 8, of the C++ Standard) bye, Christof -- http://cmeerw.org JID: cmeerw jabber.at mailto cmeerw at web.de ...and what have you contributed to the Net? Dec 11 2002
#include <stdio.h> struct A { friend int f(int i) { return 1; } }; int f(long i) { return 0; } int main() { printf("%d\n", f(0)); } AFAIK, f(long) should be invoked and not f(int). See 7.3.1.2 Namespace member definitions [namespace.memdef], paragraph 3, of the C++ standard. bye, Christof -- http://cmeerw.org JID: cmeerw jabber.at mailto cmeerw at web.de ...and what have you contributed to the Net? Dec 14 2002
Ah, no rest for the wicked <g>. "Christof Meerwald" <cmeerw web.de> wrote in message news:atgjkb$l63$1 digitaldaemon.com...#include <stdio.h> struct A { friend int f(int i) { return 1; } }; int f(long i) { return 0; } int main() { printf("%d\n", f(0)); } AFAIK, f(long) should be invoked and not f(int). See 7.3.1.2 Namespace member definitions [namespace.memdef], paragraph 3, of the C++ standard. bye, Christof -- http://cmeerw.org JID: cmeerw jabber.at mailto cmeerw at web.de ...and what have you contributed to the Net? Dec 14 2002
Not sure if Christof posted this yet.. namespace one { template<class T> struct Types { typedef int Int; }; } template<class T, class U = one::Types<int>::Int> // Error: : no type for argument 'Int' // Internal error: struct 2797 struct Values { typedef U type; }; void main() { typedef Values<int>::type def; } I tried to find chapter and verse for this but could only find 14.6.4 Dependent name resolution.. and I'm not even sure it really applies. Man, Christof is really brilliant. How did he get so smart? Richard Dec 15 2002
I believe DMC++ is behaving correctly here. f(int i) is not declared in a namespace, but in a non-local class, which according to 7.3.1.2-3 will become "a member of the innermost enclosing namespace", which in this instance is the global namespace. Hence, it should be found via normal overload rules. "Christof Meerwald" <cmeerw web.de> wrote in message news:atgjkb$l63$1 digitaldaemon.com...#include <stdio.h> struct A { friend int f(int i) { return 1; } }; int f(long i) { return 0; } int main() { printf("%d\n", f(0)); } AFAIK, f(long) should be invoked and not f(int). See 7.3.1.2 Namespace member definitions [namespace.memdef], paragraph 3, of the C++ standard. bye, Christof -- http://cmeerw.org JID: cmeerw jabber.at mailto cmeerw at web.de ...and what have you contributed to the Net? Dec 17 2002
On Tue, 17 Dec 2002 01:12:13 -0800, Walter wrote:I believe DMC++ is behaving correctly here. f(int i) is not declared in a namespace, but in a non-local class, which according to 7.3.1.2-3 will become "a member of the innermost enclosing namespace", which in this instance is the global namespace. Hence, it should be found via normal overload rules. Dec 17 2002
"Christof Meerwald" <cmeerw web.de> wrote in message news:atnudj$13hp$1 digitaldaemon.com...On Tue, 17 Dec 2002 01:12:13 -0800, Walter wrote:I believe DMC++ is behaving correctly here. f(int i) is not declared in Dec 17 2002
Not sure about the analysis of this, but it works fine if I remove namespace definitions. namespace one { template<class T> struct A { }; template<class T> A<T>& fn(A<T>& t) { return t; } typedef A<int> Type; } using one::Type; using one::fn; void main() { Type i; Type j = fn(i); // ambiguous reference to symbol // Had: one::fn(A<T>&) // and: one::fn(A<T>&) } Richard Dec 19 2002
On Tue, 17 Dec 2002 12:17:58 -0800, Walter wrote:"Christof Meerwald" <cmeerw web.de> wrote in message news:atnudj$13hp$1 digitaldaemon.com...On Tue, 17 Dec 2002 01:12:13 -0800, Walter wrote:I believe DMC++ is behaving correctly here. f(int i) is not declared in Dec 22 2002
"Christof Meerwald" <cmeerw web.de> wrote in message news:au4cno$166n$1 digitaldaemon.com...BTW, the example is not from Boost. It's inspired by some code from Dec 22 2002
I presume that goes for all of us, yes? Matthew "Walter" <walter digitalmars.com> wrote in message news:au4toe$1hl3$1 digitaldaemon.com..."Christof Meerwald" <cmeerw web.de> wrote in message news:au4cno$166n$1 digitaldaemon.com...BTW, the example is not from Boost. It's inspired by some code from Dec 22 2002
Of course! "Matthew Wilson" <dmd synesis.com.au> wrote in message news:au5a23$1q33$1 digitaldaemon.com...I presume that goes for all of us, yes? Matthew "Walter" <walter digitalmars.com> wrote in message news:au4toe$1hl3$1 digitaldaemon.com..."Christof Meerwald" <cmeerw web.de> wrote in message news:au4cno$166n$1 digitaldaemon.com...BTW, the example is not from Boost. It's inspired by some code from Dec 22 2002
"Walter" <walter digitalmars.com> schrieb im Newsbeitrag news:au4toe$1hl3$1 digitaldaemon.com...Ok. I'll keep it on the active bug list for now Dec 23 2002
"Robert M. Münch" <robert.muench robertmuench.de> wrote in message news:au6tij$2v32$1 digitaldaemon.com..."Walter" <walter digitalmars.com> schrieb im Newsbeitrag news:au4toe$1hl3$1 digitaldaemon.com...Ok. I'll keep it on the active bug list for now Dec 23 2002
namespace ns { struct B { }; struct A { A(B b); }; } ns::A::A(B b) // Error: ')' expected to close function parameter list with { } int main() { ns::B b; ns::A a(b); return 0; } bye, Christof -- http://cmeerw.org JID: cmeerw jabber.at mailto cmeerw at web.de Dec 16 2002
namespace ns { const int A = 0; struct A { A() // Error: no constructor allowed for class 'A' { } }; struct B { }; } struct C : ns::B { C() : B() // Error: 'B' is not a member of struct 'C' { } }; int main() { C c; return 0; } See 9 Classes [class], paragraph 2, of the C++ standard. bye, Christof -- http://cmeerw.org JID: cmeerw jabber.at mailto cmeerw at web.de ...and what have you contributed to the Net? Dec 21 2002
namespace ns { void f(); void g(); } void ns::f() { } void ns::g() { f(); // Error: undefined identifier 'f' } int main() { ns::g(); return 0; } See 3.4.1 Unqualified name lookup [basic.lookup.unqual], paragraph 6, of the C++ standard. bye, Christof -- http://cmeerw.org JID: cmeerw jabber.at mailto cmeerw at web.de ...and what have you contributed to the Net? Dec 21 2002
void f(); namespace ns { using ::f; } using ns::f; int main() { f(); // Error: ambiguous reference to symbol return 0; } It's the same function (see 7.3.3 The using declaration [namespace.udecl], paragraph 10 and 3.3 Declarative regions and scopes [basic.scope], paragraph 4). Workaround is simple, so it's low priority. bye, Christof -- http://cmeerw.org JID: cmeerw jabber.at mailto cmeerw at web.de ...and what have you contributed to the Net? Jan 01 2003
Quite similar to the previous one: void f(); namespace ns { using ::f; using ::f; } int main() { ns::f(); return 0; } bye, Christof -- http://cmeerw.org JID: cmeerw jabber.at mailto cmeerw at web.de ...and what have you contributed to the Net? Jan 01 2003
|