This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/11834] New: [3.4 regression] template specialization not matched


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: [3.4 regression] template specialization not matched
           Product: gcc
           Version: 3.4
            Status: UNCONFIRMED
          Severity: critical
          Priority: P1
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bangerth at dealii dot org
                CC: gcc-bugs at gcc dot gnu dot org

Here's something I extracted from boost, and which breaks my nightly
builds:
---------------------------------
template <typename T0> struct tuple {
    typedef tuple<int> tail;
};

template <> struct tuple<int> {};

template <typename L>
struct length  {
    static const int i = length<typename L::tail>::i;
};

template<>
struct length<tuple<int> > {
    static const int i = 0;
};


template <typename L, int = length<L>::i> struct M {};


template <typename C, typename A>
M<tuple<A> > foo (void (C::*)(A));

template <typename C, typename A>
M<tuple<A> > foo (void (C::*)(A) const);


struct S { void f(int) const; };

void bar() {
  foo (&S::f);
}
----------------------------------------

g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c y.cc -ftemplate-depth-4
y.cc: In instantiation of `length<typename tuple<A>::tail::tail::tail>':
y.cc:9:   instantiated from `length<typename tuple<A>::tail::tail>'
y.cc:9:   instantiated from `length<typename tuple<A>::tail>'
y.cc:9:   instantiated from `length<tuple<A> >'
y.cc:31:   instantiated from here
y.cc:9: error: incomplete type `length<typename
   tuple<A>::tail::tail::tail::tail>' used in nested name specifier

(Note that one should limit the template depth to avoid excessive screen
clutter and keep computing time reasonable.)

The error is entirely spurious: the return type of foo is 
M<tuple<int>,1>, where the second template argument of M is
deduced using length<tuple<int> >::i, which should use the
specialization of length. Even if it didn't, then the recusion
should hit the specialization in the next round, but it doesn't.

Note that the bug goes mysteriously away if I remove either
of the two foo() functions. That doesn't make much sense, since
only the second one should match the call in bar() anyway, but
that's another bug which I reported a long time ago, see PR 8271.

W.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]