December 17, 2002 Re: Another namespace bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | 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. But the next sentence in the standard is: "The name of the friend is not found by simple name lookup until a matching declaration is provided in that namespace scope (either before or after the class declaration granting friendship)." > "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? |
December 17, 2002 Re: Another namespace bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Christof Meerwald | "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 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. > > But the next sentence in the standard is: "The name of the friend is not found by simple name lookup until a matching declaration is provided in that > namespace scope (either before or after the class declaration granting > friendship)." True, but the example is a definition, not a declaration, which I believe changed things. Is this example from boost? |
December 19, 2002 Re: Another namespace bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | 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 |
December 21, 2002 Re: Another namespace bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Christof Meerwald | 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?
|
December 21, 2002 Re: Another namespace bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Christof Meerwald | 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?
|
December 22, 2002 Re: Another namespace bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | 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 > 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. >> >> But the next sentence in the standard is: "The name of the friend is not found by simple name lookup until a matching declaration is provided in > that >> namespace scope (either before or after the class declaration granting >> friendship)." > > True, but the example is a definition, not a declaration, which I believe changed things. Is this example from boost? Hmm, just found an example in the C++ standard, see 14.6.5 Friend names declared within a class template [temp.inject], paragraph 2. BTW, the example is not from Boost. It's inspired by some code from omniORB, but it's not causing any real trouble as most other compilers also get it wrong (including gcc 3.0) - but I am still hoping that I am right... bye, Christof -- http://cmeerw.org JID: cmeerw@jabber.at mailto cmeerw at web.de ...and what have you contributed to the Net? |
December 22, 2002 Re: Another namespace bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Christof Meerwald | "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 omniORB, > but it's not causing any real trouble as most other compilers also get it wrong (including gcc 3.0) - but I am still hoping that I am right... Ok. I'll keep it on the active bug list for now, but I'll prioritize the other problems first. If practical, when you post bugs, let me know if they are showstoppers for your work or not. Thanks, -Walter |
December 22, 2002 Re: Another namespace bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | 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 > omniORB, > > but it's not causing any real trouble as most other compilers also get it > > wrong (including gcc 3.0) - but I am still hoping that I am right... > > Ok. I'll keep it on the active bug list for now, but I'll prioritize the other problems first. If practical, when you post bugs, let me know if they > are showstoppers for your work or not. Thanks, -Walter > > |
December 23, 2002 Re: Another namespace bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew Wilson | 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 > > omniORB, > > > but it's not causing any real trouble as most other compilers also get > it > > > wrong (including gcc 3.0) - but I am still hoping that I am right... > > > > Ok. I'll keep it on the active bug list for now, but I'll prioritize the other problems first. If practical, when you post bugs, let me know if > they > > are showstoppers for your work or not. Thanks, -Walter > > > > > > |
December 23, 2002 Re: Another namespace bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | "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 Walter, how do you keep track of bugs and do you use a tool for this? Robert |
Copyright © 1999-2021 by the D Language Foundation