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; Reference causes error in pickingspecialization


GCC 2.95.2

Next Cube running NextSTEP 4.2, 3.3 Developer

Enclosed program demonstrates that when an explicit specialization uses pass  
by reference, the non-specialized template is picked:

g++ -o x x.cc


#include <iostream>

class A
{
public:

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

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

template <>
A::
A(int&) /* A(int) */
{
    cout << "int constructor" << endl;
}



int main(void)
{
    int i = 1;

    A b(i);

    return 0;
}

Prints "T constructor". If the & is removed, it prints "int 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]