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]

GCC 2.95.2, Next 3.3; to parent class causes error in pickingspecialization


GCC 2.95.2

Next Cube running NextSTEP 4.2, 3.3 Developer

Enclosed program demonstrates that a reference to a subclass does not match  
an explicit specialization of a reference to the parent class:

g++ -o x x.cc

#include <iostream>

class Top
{
};

class X : public Top
{
public:

    X(void)
    {
    };
};

class A
{
public:

    A(Top& x); /* X& */

    template <class T>
    A(const T x);
};

template <class T>
A::
A(const T)
{
    cout << "General constructor" << endl;
}

A::
A(Top&) /* X& */
{
    cout << "Specialized constructor" << endl;
}



int main(void)
{
    X i;

    A b(i);

    return 0;
}

Prints "General constructor". Changing Top& to X& makes it print  
"Specialized constructor".

---
Where diesel guitars from faraway bars, blast out the
best songs from our holy wars. Coyote carnival catches
on fire, all the cops in the world pick us up on radar.
Jim McKelvey  mckelvey@fafnir.com

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