This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Bug under MkLinux EGCS


While compiling DOC++, the attached file failed as follows:

I created a file "testfile.cpp" which does nothing but #include
"McSorter.h" (attached).
The  sequence follows.

src/65> gcc testfile.cpp
McSorter.h: In function `void sort(T *, int)':
In file included from testfile.cpp:1:
McSorter.h:78: Internal compiler error.
McSorter.h:78: Please submit a full bug report to
`egcs-bugs@cygnus.com'.
src/66> vi McSorter.h


The version is:

src/68> gcc -v
Reading specs from
/opt/egcs/lib/gcc-lib/powerpc-unknown-linux-gnulibc1/egcs-2.90.25/specs
gcc version egcs-2.90.25 980302 (egcs-1.0.2 prerelease)
src/69>


mike

#ifndef DEFsorter		// prevent multiple includes
#define DEFsorter
#include <assert.h>

/* \Section{Implementation}
    This is quicksort.
 */
//@Man:	sorting	functions
//@{
/*@ManDoc:
    The template function #sort# sorts an array #t# holding #n# elements of type
    #T# using #c# for comparisions. Class #COMPARATOR# must be provide an
    overloaded #operator()(const T& t1,const T& t2)#, that returns
    \begin{description}
    \item[#<0#]		if #t1# is to appear before #t2#,
    \item[#==0#]	if #t1# and #t2# can appear in any order or
    \item[#>0#]		if #t1# is to appear after #t2#.
    \end{description}
 */
template< class COMPARATOR, class T >
static void	sort( T* t, int end, COMPARATOR& compare, int start = 0 )
{
    int		i0, i1, j ;
    double	c ;

    T	work, mid, tmp ;

    work             = t[start] ;
    t[start]         = t[(start+end)/2] ;
    t[(start+end)/2] = work ;

    mid  = t[start] ;
    work = t[end-1] ;

    for(i0 = i1 = start, j = end-1 ; i1 < j ; )
    {
	c = compare(mid,work) ;
	if( c > 0 )
	{
	    tmp   = t[i0] ;
	    t[i0] = work ;
	    i0++ ;
	    i1++ ;
	    work  = t[i1] ;
	    t[i1] = tmp ;
	}
	else if( c < 0 )
	{
	    t[j] = work ;
	    --j ;
	    work = t[j] ;
	}
	else
	{
	    i1++ ;
	    tmp   = t[i1] ;
	    t[i1] = work ;
	    work  = tmp ;
	}
    }

    if( start < i0-1 )
	sort( t, i0, compare, start ) ;
    if( i1+1 < end )
	sort( t, end, compare, i1+1 ) ;
}

#ifndef	_CRAYMPP
/*@ManDoc:
    The template function #sort# sorts an array #t# holding #n# elements of type
    #T#, which must provide an #operator>#.
 */
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) ;
	}
#endif	//@ _CRAYMPP
//@}


#endif // #DEFsorter#

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]