Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ARIZONA.EDU!olson%modular.UUCP From: olson%modular.UUCP@ARIZONA.EDU (Jon Olson) Newsgroups: gnu.gcc.bug Subject: (none) Message-ID: <8903230545.AA21429@> Date: 23 Mar 89 05:45:12 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 100 To whom it may concern, Here's a bit of code that causes a segment violation in GCC V1.33 on a Sun-3 running SunOS 4.0. Seems that GCC is generating a SUBREG(MEM). The routine `equiv_constant' in cse.c expects only SUBREG(REG) and causes a segment violation when given SUBREG of anything else. Although I'm not sure if GCC should even generate a SUBREG(MEM), I put in the following quicky patch in cse.c so that this would not generate a segment violation. *** cse.c.save Wed Feb 22 09:10:28 1989 --- cse.c Wed Feb 22 09:08:09 1989 *************** *** 2391,2397 **** return tem1; /* If integer truncation is being done with SUBREG, we can compute the result. */ ! else if (GET_CODE (x) == SUBREG && && SUBREG_WORD (x) == 0 && (tem1 = qty_const[reg_qty[REGNO (SUBREG_REG (x))]]) != 0 /* Make sure it is a known integer. */ && GET_CODE (tem1) == CONST_INT --- 2391,2398 ---- return tem1; /* If integer truncation is being done with SUBREG, we can compute the result. */ ! else if (GET_CODE (x) == SUBREG && GET_CODE (SUBREG_REG(x)) == REG ! && SUBREG_WORD (x) == 0 && (tem1 = qty_const[reg_qty[REGNO (SUBREG_REG (x))]]) != 0 /* Make sure it is a known integer. */ && GET_CODE (tem1) == CONST_INT ---------------------Sample code which generates SEGV---------------------- #define X$CHAR 1 #define X$WORD 2 #define X$INT 3 #define X$FLOAT 4 #define X$UNSIGNED 8 union ANY { char *c; unsigned char *uc; short *s; unsigned short *us; int *i; unsigned int *ui; float *f; }; static convertfield( pto, pfrom, new_type, old_type, machine ) union ANY pto, pfrom; unsigned short new_type, old_type; int machine; { union { char c; short s; int i; float f; } u; unsigned char isint = 1; #ifndef vms if( machine ) { switch( old_type & 0xFF ) { case X$CHAR: u.c = *pfrom.c; pfrom.c = &u.c; break; case X$WORD: u.s = *pfrom.s; vaxshort( pfrom.s = &u.s ); break; case X$INT: u.i = *pfrom.i; vaxint( pfrom.i = &u.i ); break; case X$FLOAT: u.f = *pfrom.f; vaxfloat( pfrom.f = &u.f ); break; } } #endif switch( old_type & 0xFF ) { case X$CHAR: u.i = old_type & X$UNSIGNED ? *pfrom.uc : *pfrom.c; break; case X$WORD: u.i = old_type & X$UNSIGNED ? *pfrom.us : *pfrom.s; break; case X$INT: u.i = *pfrom.i; break; case X$FLOAT: u.f = *pfrom.f; isint = 0; break; } switch( new_type & 0XFF ) { case X$CHAR: *pto.c = isint ? u.i : (int)u.f; break; case X$WORD: *pto.s = isint ? u.i : (int)u.f; break; case X$INT: *pto.i = isint ? u.i : (int)u.f; break; case X$FLOAT: *pto.f = isint ? (float)u.i : u.f; break; } } ---------------------------------------------------------------- Jon Olson, Modular Mining Systems 1210 E. Pennsylvania St. Tucson, AZ 85714 USENET: {ihnp4,allegra,cmcl2,hao!noao}!arizona!modular!olson INTERNET: modular!olson@arizona.edu