public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/11834] New: [3.4 regression] template specialization not matched
@ 2003-08-06 14:51 bangerth at dealii dot org
  2003-08-06 15:33 ` [Bug c++/11834] " pinskia at physics dot uc dot edu
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: bangerth at dealii dot org @ 2003-08-06 14:51 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2003-08-21  5:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-06 14:51 [Bug c++/11834] New: [3.4 regression] template specialization not matched bangerth at dealii dot org
2003-08-06 15:33 ` [Bug c++/11834] " pinskia at physics dot uc dot edu
2003-08-06 18:22 ` bangerth at ices dot utexas dot edu
2003-08-06 18:30 ` pinskia at physics dot uc dot edu
2003-08-06 21:10 ` janis187 at us dot ibm dot com
2003-08-21  5:50 ` cvs-commit at gcc dot gnu dot org
2003-08-21  5:54 ` mmitchel at gcc dot gnu dot org

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).