This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/33518] invalid Koenig lookup
- From: "bangerth at dealii dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Sep 2007 18:23:18 -0000
- Subject: [Bug c++/33518] invalid Koenig lookup
- References: <bug-33518-6008@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #3 from bangerth at dealii dot org 2007-09-23 18:23 -------
This actually turns out to be a serious bug in several different ways.
Here's self-contained code:
-------------------
namespace X {
template<typename T> struct H { typedef typename T::type type; };
template<typename T> typename H<T>::type foo(T);
}
namespace M {
struct A {};
using X::foo;
}
namespace N {
template <class> struct S {};
class Q : S<M::A> {};
int foo(Q);
}
int i = foo (N::Q());
---------------------
We get this:
g/x> c++ -c y.ii
y.ii: In instantiation of 'X::H<N::Q>':
y.ii:18: instantiated from here
y.ii:2: error: no type named 'type' in 'class N::Q'
Note that in the call to foo, all arguments have associated namespace
N, so X::foo shouldn't be considered. The fact that we do is bug 1.
Bug 2 is that even if we consider X::foo, we should realize that the
return type of X::foo can't be instantiated for this template argument,
since X::H<T>::type doesn't exist. That we don't silently give up means
that we aren't doing SFINAE right.
I'll try to come up with a wrong-code version of this in a minute.
W.
--
bangerth at dealii dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid
Summary|unused code changes the |invalid Koenig lookup
|result of name lookup |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33518