This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Partial ordering bug (?) in egcs
- To: tveldhui at seurat dot uwaterloo dot ca
- Subject: Re: Partial ordering bug (?) in egcs
- From: Mark Mitchell <mark at markmitchell dot com>
- Date: Mon, 10 Aug 1998 13:08:54 -0700
- CC: derrick at tapir dot Caltech dot EDU, egcs-bugs at cygnus dot com, blitz-bugs-archive at monet dot uwaterloo dot ca
- References: <199808101939.PAA53124@seurat.uwaterloo.ca>
- Reply-to: mark at markmitchell dot com
template<int N>
class IndexPlaceholder {
};
template<class T, int N>
class Array {
};
// #1
template<class T1, class T2>
void max(const T1& a, const T2& b)
{
}
// #2
template<class T_numtype, int N_rank, int N_index>
inline void
max(const Array<T_numtype, N_rank>& array, IndexPlaceholder<N_index>)
{
}
int main()
{
Array<int,2> A;
IndexPlaceholder<2> j;
max(A,j); // should match #2?
}
The first relevant question is: which is more specialized, #1 or #2?
Certainly #1 is not more specialized than #2. So, is #2 more
specialized than #1? But, equally certainly, #2 is not a
specialization of #1, since there's no choice of `T2' that makes
`const T2&' the same as `IndexPlaceholder<N_index>'. So, neither
version is more specialized. Then, we just have to do overload
resolution. The program is now equivalent to:
class IndexPlaceholder {};
class Array {};
void max(const Array&, const IndexPlaceholder&);
void max(const Array&, IndexPlaceholder);
int main()
{
Array A;
IndexPlaceholder j;
max(A,j);
}
EDG agrees with G++ that this program is ambiguous.
Thus, in short, I think G++ is correct in this case.
--
Mark Mitchell mark@markmitchell.com
Mark Mitchell Consulting http://www.markmitchell.com