From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23717 invoked by alias); 21 Apr 2003 19:26:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 23688 invoked by uid 71); 21 Apr 2003 19:26:01 -0000 Date: Mon, 21 Apr 2003 19:26:00 -0000 Message-ID: <20030421192601.23672.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Dean Foster Subject: Re: c++/10437: "using namespace" at global scope creates incorrect code Reply-To: Dean Foster X-SW-Source: 2003-04/txt/msg00902.txt.bz2 List-Id: The following reply was made to PR c++/10437; it has been noted by GNATS. From: Dean Foster To: bangerth@dealii.org, dean@foster.net, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org, gcc-gnats@gcc.gnu.org Cc: Subject: Re: c++/10437: "using namespace" at global scope creates incorrect code Date: 21 Apr 2003 19:18:52 -0000 Sorry about forcing you to do more of the reduction. I did at least remove several 1000 lines of code! But, every time I tried reducing it further, I ended up removing the problem. Thanks. I'm willing to agree that that I've have an error/ambiguity in my code. But I don't understand why bringing in a namespace that isn't being called should change the ambiguity status. In other words, main() { using namespace foo; /* ... */ // no error } doesn't generate an error. Neither does: main() { /* ... */ // no error } But, the following does generate an error: using namespace foo; main() { /* ... */ // generates error } It seems that the first and the 3rd should be the same. So maybe the problem is that the third one is correct and that the first two should catch the ambigity? Or is my understanding of namespaces incorrect? later, dean ============================================================================= Dean Foster dean@foster.net Statistics, Wharton, U. Penn 215 898 8233 Philadelphia PA 19104-6340 http://diskworld.wharton.upenn.edu > Date: 21 Apr 2003 15:06:07 -0000 > From: bangerth@dealii.org > Reply-To: bangerth@dealii.org, dean@foster.net, gcc-bugs@gcc.gnu.org, > gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org, gcc-gnats@gcc.gnu.org > X-SBRule: Spammy To: Header > X-SBRule: Other Spammy Headers > > Synopsis: "using namespace" at global scope creates incorrect code > > State-Changed-From-To: open->closed > State-Changed-By: bangerth > State-Changed-When: Mon Apr 21 15:06:06 2003 > State-Changed-Why: > I don't think this is a bug. After quite some reducing, > your code looks like this: > --------------------------- > struct X { > int operator-(const X& it); > }; > > template > struct Y { > typedef typename T::SOME_TYPE SOME_TYPE; > typedef int type; > }; > > #ifdef BUG > template typename Y::type operator-(T,T); > #endif > > int x = X() - X(); > ----------------------------- > (I replaced your using directive by the conditional > statement -- both just bring into visibility the > operator-.) > > What happens is that in the minus statement (which was > inside a std:: function in your example), both possible > operator- are considered, i.e. the member function and > the global one. The global one requires instantiation > of Y, at which point we realize that X::SOME_TYPE does > not exist: > g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c x.cc -DBUG > x.cc: In instantiation of `Y': > x.cc:15: instantiated from here > x.cc:7: error: no type named `SOME_TYPE' in `struct X' > > Tracing back where this happens in your code is a little > more complicated, but I guess this is what happens -- you > try to use __gnu_cxx::normal_iterator::const_iterator > when bringing into scope the function in the namespace, > but this const_iterator doesn't exist. > > Wolfgang > > http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10437 >