This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/37066] New: partial specialization of function depends on the order
- From: "marc dot glisse at normalesup dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 Aug 2008 13:00:05 -0000
- Subject: [Bug c++/37066] New: partial specialization of function depends on the order
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
In the following code, adapted from gmpxx, the output is HELLO2. If however I
change the order of the two partial specializations, the output becomes HELLO1.
At least one other compiler I tried outputs HELLO1 in both cases. I know that I
can remove the "template<>" and overload the function instead of partially
specializing it, but I would like to understand why the current code is
failing.
#include <iostream>
struct mpz_t{};
template <class T, class U>
class __gmp_expr{};
template <class T, class U>
void __gmp_set_expr(const __gmp_expr<T, U> &);
typedef __gmp_expr<mpz_t, mpz_t> mpz_class;
template <>
void __gmp_set_expr(const __gmp_expr<mpz_t, mpz_t> &expr)
{
std::cerr << "HELLO1\n";
}
template <class T>
void __gmp_set_expr(const __gmp_expr<mpz_t, T> &expr)
{
std::cerr << "HELLO2\n";
}
int main(){
mpz_class a;
mpz_t t;
__gmp_set_expr(a);
}
--
Summary: partial specialization of function depends on the order
Product: gcc
Version: 4.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: marc dot glisse at normalesup dot org
GCC host triplet: i486-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37066