public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/2127: namespace problems
@ 2002-02-01  4:03 jason
  0 siblings, 0 replies; 4+ messages in thread
From: jason @ 2002-02-01  4:03 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, jason, nobody, reichelt

Synopsis: namespace problems

Responsible-Changed-From-To: unassigned->jason
Responsible-Changed-By: jason
Responsible-Changed-When: Fri Feb  1 04:03:32 2002
Responsible-Changed-Why:
    got it
State-Changed-From-To: analyzed->closed
State-Changed-By: jason
State-Changed-When: Fri Feb  1 04:03:32 2002
State-Changed-Why:
    This is not a bug.  The candidates considered for the == expression in dummy<S2> are those visible at the point of definition of dummy (only the S1 version) and those in the associated namespace of S2 (also only the S1 version).  You must move the S2 version into the namespace.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=2127


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: c++/2127: namespace problems
@ 2002-02-01  7:36 Reichelt
  0 siblings, 0 replies; 4+ messages in thread
From: Reichelt @ 2002-02-01  7:36 UTC (permalink / raw)
  To: jason; +Cc: gcc-prs

The following reply was made to PR c++/2127; it has been noted by GNATS.

From: Reichelt <reichelt@igpm.rwth-aachen.de>
To: jason@redhat.com
Cc:  
Subject: Re: c++/2127: namespace problems
Date: Fri, 1 Feb 2002 16:26:22 +0100

 Hello again,
 
 On 1 Feb, you wrote wrote:
 
 >>> This is not a bug.  The candidates considered for the == expression in dummy<S2>
 >>> are those visible at the point of definition of dummy (only the S1
 >>> version) and those in the associated namespace of S2 (also only
 >>> the S1 version).  You must move the S2 version into the namespace.
 >
 me> I'm not quite convinced, because the code compiles fine, if you remove
 me> the first version of the == operator (the S1-version inside the
 me> namespace). According to your explanation the code shouldn't compile
 me> in this case.
 > 
 > No, it shouldn't, but g++ doesn't implement 2-phase name lookup properly.
 > 
 me> The only thing that might be possible IMHO is that the definition
 me> outside the namespace is shadowed by the one inside
 > 
 > That is indeed what is happening in g++ currently.  It does a normal lookup
 > in the scope of the function, which finds the S1 version and stops.
 
 Ok, you win ;-)
 
 By the way, SGI's native compiler (which has some problems with template lookup,
 it doesn't do Koenig-lookup for example) accepts the code, whereas Comeau's online
 compiler rejects the code.
 
 Greetings,
 Volker Reichelt
 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: c++/2127: namespace problems
@ 2002-02-01  5:16 Jason Merrill
  0 siblings, 0 replies; 4+ messages in thread
From: Jason Merrill @ 2002-02-01  5:16 UTC (permalink / raw)
  To: jason; +Cc: gcc-prs

The following reply was made to PR c++/2127; it has been noted by GNATS.

From: Jason Merrill <jason@redhat.com>
To: Reichelt <reichelt@igpm.rwth-aachen.de>
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: c++/2127: namespace problems
Date: Fri, 01 Feb 2002 13:07:38 +0000

 >>>>> "Reichelt" == Reichelt  <reichelt@igpm.rwth-aachen.de> writes:
 
 >> This is not a bug.  The candidates considered for the == expression in dummy<S2>
 >> are those visible at the point of definition of dummy (only the S1
 >> version) and those in the associated namespace of S2 (also only
 >> the S1 version).  You must move the S2 version into the namespace.
 
 > I'm not quite convinced, because the code compiles fine, if you remove
 > the first version of the == operator (the S1-version inside the
 > namespace). According to your explanation the code shouldn't compile
 > in this case.
 
 No, it shouldn't, but g++ doesn't implement 2-phase name lookup properly.
 
 > The only thing that might be possible IMHO is that the definition
 > outside the namespace is shadowed by the one inside
 
 That is indeed what is happening in g++ currently.  It does a normal lookup
 in the scope of the function, which finds the S1 version and stops.
 
 Jason


^ permalink raw reply	[flat|nested] 4+ messages in thread

* c++/2127: namespace problems
@ 2001-04-01  0:00 reichelt
  0 siblings, 0 replies; 4+ messages in thread
From: reichelt @ 2001-04-01  0:00 UTC (permalink / raw)
  To: gcc-gnats

>Number:         2127
>Category:       c++
>Synopsis:       namespace problems
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Wed Feb 28 12:16:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Volker Reichelt
>Release:        gcc version 3.0 20010227 (prerelease)
>Organization:
>Environment:
mips-sgi-irix6.5
>Description:
Compiling the following lines of code

namespace XXX {

struct S1 { int i; };
struct S2 { int i; };

bool operator == ( const S1&, const S1& ) { return true; }

template <class T> bool dummy ( const T &x ) { return x==x; }

}

bool operator == ( const XXX::S2&, const XXX::S2& ) { return true; }

void f () { XXX::S2 A; XXX::dummy(A); }


I get the error message

NamespaceBug.cpp: In function `bool XXX::dummy(const T&) [with T = XXX::S2]':
NamespaceBug.cpp:14:   instantiated from here
NamespaceBug.cpp:8: no match for `const XXX::S2& == const XXX::S2&' operator
NamespaceBug.cpp:6: candidates are: bool XXX::operator==(const XXX::S1&, const XXX::S1&)

Obviously the compiler fails to find the second operator ==.
Without namespaces or if one leaves out the first operator ==
everything works fine.
(gcc 2.95 shows the same behaviour, so this is not really a
regression. But because gcc 2.95 isn't so picky about the
namespace std, the code worked at least for XXX=std, whereas
gcc 3.0 fails for any namespace name.)
>How-To-Repeat:
g++ -c NamespaceBug.cpp
(assuming the file is named 'NamespaceBug.cpp')
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-02-01 15:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-01  4:03 c++/2127: namespace problems jason
  -- strict thread matches above, loose matches on Subject: below --
2002-02-01  7:36 Reichelt
2002-02-01  5:16 Jason Merrill
2001-04-01  0:00 reichelt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).