public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: bangerth@dealii.org
To: dean@foster.net, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org,
	nobody@gcc.gnu.org
Subject: Re: c++/10437: "using namespace" at global scope creates incorrect code
Date: Mon, 21 Apr 2003 15:06:00 -0000	[thread overview]
Message-ID: <20030421150607.22465.qmail@sources.redhat.com> (raw)

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 <class T>
    struct Y {
        typedef typename T::SOME_TYPE SOME_TYPE;
        typedef int type;
    };
    
    #ifdef BUG
    template <class T> typename Y<T>::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>':
    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


             reply	other threads:[~2003-04-21 15:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-21 15:06 bangerth [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-04-25 19:46 Wolfgang Bangerth
2003-04-25 19:38 bangerth
2003-04-21 20:06 Wolfgang Bangerth
2003-04-21 19:26 Dean Foster
2003-04-19  0:36 dean

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030421150607.22465.qmail@sources.redhat.com \
    --to=bangerth@dealii.org \
    --cc=dean@foster.net \
    --cc=gcc-bugs@gcc.gnu.org \
    --cc=gcc-gnats@gcc.gnu.org \
    --cc=gcc-prs@gcc.gnu.org \
    --cc=nobody@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).