g++ 2.95.2 bug

John H. Spicer jhs@edg.com
Fri Dec 31 20:54:00 GMT 1999


"Martin v. Loewis" wrote:
> 
> > The deduction is done as if the function was being called.
> 
> That does not work. First, 14.8.2.1/1 talks about arguments, and there
> are no arguments. It may be possible to synthesize arguments, but that
> is not explained anywhere.
> 
> More important, I believe this would break a number of cases that
> currently work (*). At the moment,
> 
>    template<class T>void foo(X<T>&,T&){}
> 
> is more specialized than
> 
>   template<class T,class U>void foo(X<T>&,U&){}
> 
> If I would use 14.8.2.1 for partial ordering, that would not be the
> case anymore. To see that, I synthesize a type A1, giving me 'void
> foo(X<A1>&,A1&)', and performing deduction agains the second.
> 
> Therefore, I have to compare X<T>& with X<A1>&, and U& with
> A1&. According to 14.8.2.1/2, I drop the references on the parameter
> types, having now to compare X<T> with X<A1>&, and U with A1&.
 
> U could be deduced as A1& (giving me references to references!?!).
> T cannot be deduced, so deduction fails.
> 
> Please note that this is not an issue for a true function call, since
> references on expressions are dropped in 5p6.

Of course you have to drop the reference types on arguments for this
very reason.

> 
> So I think the rules for function calls don't work for partial
> ordering. If you want removal of top-level references in partial
> ordering, you'll have to make new rules.

As I said before, this should be clarified.  

> 
> > Also, note that the example following paragraph 5 illustrates that
> > "T" and "T&" are not partially ordered relative to one another,
> > which is the consequence of top-level references being removed.
> 
> Since g++ does not remove top-level references, it consequently
> accepts this example completely, invoking "void g<float>(float &)".
> 
> Should I raise another issue, or are the existing ones sufficient for
> some action by the committee?
> 

I think an issue should be raised for this.

John.



More information about the Gcc-bugs mailing list