public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/33518] unused code changes the result of name lookup
Date: Sun, 23 Sep 2007 18:09:00 -0000	[thread overview]
Message-ID: <20070923180911.20975.qmail@sourceware.org> (raw)
In-Reply-To: <bug-33518-6008@http.gcc.gnu.org/bugzilla/>



------- Comment #2 from bangerth at dealii dot org  2007-09-23 18:09 -------
This indeed looks like a bug. Take this:
---------------------
#include <iterator>

namespace M {
  struct A {};
  using std::distance;
}

namespace N
{
  template <class> struct S {};
  class Q : S<M::A> {};
  int distance(Q,Q);
}

int i = distance (N::Q(), N::Q());
----------------
I would expect this to compile: all arguments to the call to distance()
have associated namespace N, so we would expect that the compiler finds
N::distance. However, apparently, gcc also performs the derived-to-base
conversion to find S<M::A> and concludes that namespace M is also
associated from where it tries to use std::distance and gives the error

g/x> c++ -c y.cc
/usr/include/c++/4.1.2/bits/stl_iterator_base_types.h: In instantiation of
'std::iterator_traits<N::Q>':
y.cc:15:   instantiated from here
/usr/include/c++/4.1.2/bits/stl_iterator_base_types.h:129: error: no type named
'iterator_category' in 'class N::Q'
/usr/include/c++/4.1.2/bits/stl_iterator_base_types.h:130: error: no type named
'value_type' in 'class N::Q'
/usr/include/c++/4.1.2/bits/stl_iterator_base_types.h:131: error: no type named
'difference_type' in 'class N::Q'
/usr/include/c++/4.1.2/bits/stl_iterator_base_types.h:132: error: no type named
'pointer' in 'class N::Q'
/usr/include/c++/4.1.2/bits/stl_iterator_base_types.h:133: error: no type named
'reference' in 'class N::Q'

It shouldn't be hard to produce a wrong-code bug from this.

If someone wants to beat me to producing something without the include
file, feel free...

W.


-- 

bangerth at dealii dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-09-23 18:09:10
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33518


  parent reply	other threads:[~2007-09-23 18:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-21 15:40 [Bug c++/33518] New: " marc dot glisse at normalesup dot org
2007-09-22  4:32 ` [Bug c++/33518] " bangerth at dealii dot org
2007-09-23 18:09 ` bangerth at dealii dot org [this message]
2007-09-23 18:23 ` [Bug c++/33518] invalid Koenig lookup bangerth at dealii dot org
2007-09-23 18:29 ` [Bug c++/33518] invalid Koenig lookup/incorrect SFINAE bangerth at dealii dot org
2007-09-23 19:58 ` rguenth at gcc dot gnu dot org
2007-09-23 20:57 ` bangerth at dealii dot org

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=20070923180911.20975.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).