The test code:
template<class IntT, IntT X>
struct A
{
IntT val_;
A() : val_(X) {}
A(IntT arg) : val_(arg) {}
template<IntT X2>
A(const A<IntT, X2>& other) : val_(other.val_) {}
};
int main(int argc, char** argv)
{
A<int, 42> a;
A<int, 100> b = a;
A<unsigned, 42u> c;
A<unsigned, 100u> d = c;
A<long, 42l> e;
A<long, 100l> f = e;
}
fails to compile on gcc 4.3.2:
case.cpp: In function 'int main(int, char**)':
case.cpp:19: error: conversion from 'A<unsigned int, 42u>' to non-scalar type
'A<unsigned int, 100u>' requested
case.cpp:22: error: conversion from 'A<long int, 42l>' to non-scalar type
'A<long int, 100l>' requested
The first conversion is OK, but the other two conversions are being flagged as
errors. Even if I were to put the conversions in a different order, the same
results... first one is OK, other two fail.
--
Summary: Multiple instantiations of template constructor fail
Product: gcc
Version: 4.3.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: apatterno at gmail dot com
GCC build triplet: i686-pc-cygwin
GCC host triplet: i686-pc-cygwin
GCC target triplet: i686-pc-cygwin
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42466