Miscompilation of tetex-1.0.6 by gcc-2.95
Martin Kahlert
martin.kahlert@mchp.siemens.de
Thu Jul 22 00:26:00 GMT 1999
Hi,
i simplified Ernst program quite a bit ;-)
Martin, -fstrict-aliasing has nothing to do with that.
It seems to be a more fundamental optimizer bug.
To show it, do this:
gcc -O1 -o test1 test.c
gcc -O2 -o test2 test.c
./test2
hier is a bug: i=54
Bad GF file: Unexpected 55 command between characters!
./test1
hier is a bug: i=55
Bad GF file: Unexpected 69 command between characters!
I append the shortest version which shows the tetex bug.
gcc -v:
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95/specs
gcc version 2.95 19990718 (prerelease)
#include <stdio.h>
int gfbyte ( void )
{
static int i=0;
static int x[]=
{
69, 55, 69, 69
};
if (i<3)
i++;
else
i=0;
return x[i];
}
int main( void )
{
int pkloc,gfcom=249,i,j,k ;
i = gfbyte ();
do {
if ( i == 0 )
j = 46 ;
else
j = gfbyte () ;
i = i - 1 ;
} while ( ! ( j != 32 ) ) ;
i = i + 1 ;
if ( i == 0 )
k = -0 ;
else
k = i + 0 ;
if ( k > 255 )
pkloc = pkloc + 1 ;
else
pkloc = pkloc + 1 ;
printf("hier is a bug: i=%d\n",i);
k = 1 ;
if ( k <= i)
do
j = gfbyte () ;
while ( k++ < i ) ;
do {
gfcom = gfbyte () ;
switch ( gfcom )
{case 67 :
case 68 :
gfbyte () ;
gfbyte () ;
gfbyte () ;
i = gfbyte () ;
do
gfcom = gfbyte () ;
while ( ! ( gfcom == 69 ) ) ;
break ;
default:
fprintf( stderr , "%s%s%ld%s%c\n", "Bad GF file: " , "Unexpected " , (long)gfcom , " command between characters" , '!' ) ;
exit ( 1 ) ;
break ;
}
} while ( ! ( gfcom == 248 ) ) ;
}
--
esa$ gcc -Wall -o ariane5 ariane5.c
ariane5.c: 666: warning: long float implicitly truncated to unsigned type
esa$ ariane5
More information about the Gcc-bugs
mailing list