Subject: gcc 2.7.2.1 bug
To: Mark Brinicombe <amb@physig4.ph.kcl.ac.uk>
From: Ale Terlevich <A.I.Terlevich@durham.ac.uk>
List: port-arm32
Date: 11/20/1996 15:16:06
 Hi,  

  Whilst trying to compile xtank, I came accross some code which makes gcc
a tad upset.

 I've condensed it down to 47 lines of code (although all meaning in the 
code has gone, it's still legal C source and still trips gcc up)

  It compiles fine without optimisation.

  I thought I'd include the source with this mail as it's short, and I 
don't know who else to send it to!

  Here's the error I get with -O  (no errors without it)

garp:~> gcc -c -O junk.c
junk.c: In function `MyVehicleIsClosest':
junk.c:47: internal error--insn does not satisfy its constraints:
(insn:HI 32 170 173 (set (reg/v:SI 2 r2)
        (plus:SI (mult:SI (reg/v:SI 2 r2)
                (reg/v:SI 2 r2))
            (reg:SI 3 r3))) 36 {mulsi3+3} (insn_list 20 (insn_list 30 (nil)))
    (expr_list:REG_DEAD (reg/v:SI 2 r2)
        (expr_list:REG_DEAD (reg:SI 3 r3)
            (nil))))
gcc: Internal compiler error: program cc1 got fatal signal 6

 and here's the source

Ale.
-------------------------

/*
$Author: lidl $
$Id: tagman.c,v 1.1.1.1 1995/02/01 00:25:47 lidl Exp $
*/

typedef struct {int s,n;} Box;
typedef struct { int box_x,box_y; } cpos;
typedef struct {int team;cpos loc;} Vehicle_info;	

typedef struct {
    Box box[30][30];
    Vehicle_info  stVehicles[20];
    int box_x,box_y,team;
} Environment;

int MyVehicleIsClosest(pEnv)
Environment *pEnv;
{
    int iRetCode = 1;
    int iNumFound = 0;
	int iDiffX = pEnv->box_x;
	int iDiffY = pEnv->box_y;
	int iDist = iDiffX * iDiffX + iDiffY * iDiffY;

        int iCtr,iCtr2;
    
        for (; iCtr ;)
        {
            if ( pEnv->team)
            {
				if (pEnv->box_y)
				{
					if (SomeFn(&pEnv->stVehicles[iCtr2]))
					{
	                    iDiffX = pEnv->stVehicles[iCtr2].loc.box_x;
	                     	    if (iDiffX  < iDist)
					    {
                            iNumFound++;
							if (iNumFound > 1)
						        iRetCode = 0;
					    }
					}
				}
			}
		}
	return (iRetCode);
}