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: Sat, 06 Jun 1998 16:25:04 -0700
- Newsgroups: cygnus.egcs
- Organization: http://www.cantrip.org/
- References: <ord8cnlt30.fsf@zecarneiro.lsd.dcc.unicamp.br>, <Pine.LNX.3.96.980606003134.23023B-100000.cygnus.egcs@earth.terran.org>
B. James Phillippe wrote:
>
> On 5 Jun 1998, Alexandre Oliva wrote:
>
> > Artur Jorge Azevedo Carvalho <ajc@inescn.pt> writes:
> >
> > > the error seems to be in having a struct defined inside a function
> > > template
> >
> > Yup, AFAI recall, the problem has to do with generating templates of
> > local classes in function templates. Bear in mind, however, that
> > using local classes as template arguments is *not* ANSI/ISO C++
> > ([temp.arg.type]/2 explicitly forbits this), it is an extension
> > provided by gcc and egcs.
>
> I'm sorry, I missed the first part of this thread. Can you provide a small
> snippet of code that illustrates this? You say this is explicitly
> forbidden from ISO C++ and it is supported anyway by egcs; is there a
> warning or compiler flag that prevents someone from inadvertently writing
> this non-portable code?
Evidently the warning currently has the form:
In function `void sort(T *, int)':
In file included from teste.cc:1:
Internal compiler error.
for code (as requested)
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); // this is the STL template algorithm.
}
A compiler crash isn't ideal as a warning,
but it's better than nothing. :-)
Nathan Myers
ncm@cantrip.org