This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: bug report...
- To: egcs at cygnus dot com
- Subject: Re: bug report...
- From: Nathan Myers <ncm at cygnus dot com>
- Date: Sun, 07 Jun 1998 18:40:11 -0700
- Newsgroups: cygnus.egcs
- Organization: http://www.cantrip.org/
- References: <ord8cnlt30.fsf@zecarneiro.lsd.dcc.unicamp.br>, <u9pvgm9hlb.fsf.cygnus.egcs@yorick.cygnus.com>
Jason Merrill wrote:
> > template< class T >
> > void sort( T* t, int n )
> > { struct { int operator()(T i, T j)
> > { return (i < j) ? -1 : ((j < i) ? 1 : 0); }
> > } c;
> > sort(t,n,c,0);
> > }
>
> The compiler doesn't give any diagnostic for this testcase because there's
> nothing wrong with it. It doesn't instantiate any templates using a local
> class; in fact, it doesn't instantiate any templates at all.
Not to be contrary, but that call to sort() looks to me like a template
function call. I don't know why it's different from the STL sort, or why
he didn't bother to declare it; an example using the STL version would be
more like:
#include <algorithm>
template< class T >
void sort( T* t, int n )
{ struct { int operator()(T i, T j)
{ return (i < j); }
} c;
std::sort(t,t+n,c);
}
and does deserve a warning.
Nathan