gcc 2.95 optimizer bug?

Mumit Khan khan@xraylith.wisc.EDU
Sat Jul 31 19:50:00 GMT 1999


Joe Ramey <ramey@csc.ti.com> writes:
> I am using gcc 2.95 on a Sun Ultra-2 workstation running Solaris
> 2.5.1.  I was compiling the teTeX-1.0 package and found that the mf
> (MetaFont) program was dumping core.  When I compiled with gcc 2.8.1 I
> did not have this problem.  Also I found that it will dump core if
> compiled with gcc 2.95 using the -O2 option, but not when I am using
> the -O1 option.

Unless I'm missing something very obvious, this should bomb with any
compiler.

First of all, you allocate 100 entries for mem, but then access 1024'th
entry (lomemmax = rover + 1000).

   lomemmax = rover + 1000 ;
   mem [lomemmax ].hhfield .v.RH = 0 ;

Then, in the following snippet:

   {register integer for_end; k = memtop - 2 ;for_end = memtop ; if ( k <= 
   for_end) do 
     mem [k ]= mem [lomemmax ];
   while ( k++ < for_end ) ;} 
  
k becomes -2 (memtop is initialized to 0), which is obviously a problem.

Did you run this code under a memory debugger?

Feel free to point out if I'm overlooking something fairly obvious here.

Regards,
Mumit



More information about the Gcc-bugs mailing list