From: Johan K. <joh...@id...> - 2003-05-08 12:56:38
|
> void d (int); > > unsigned char *p; > > void main (void) > { > unsigned i; > > p = 0; > i = 0; > do > { > p[i] = 0; > if (i % 1000 == 0) > d (i); > } while (++i < 0x8000); > } > > > gen.c:3955: genMod: Assertion `0' failed. > > SDCCcse.c 1.17 (cseBBlock):1540 inserts a POINTER in the > type chain of IC_LEFT (BBlock 2, 1. ic, iTemp8). > This changes IC_LEFT of the 2. ic too, where the modulo is > computed. > SDCCopt.c 1.30 (convertToFcall):516 doesn't convert the mod > (2. ic) to an Fcall, because IS_INTEGRAL(leftType) is false. > IS_INTEGRAL checks type, not etype. etype is still integral. > > I see what's happening, but I've no idea, at which stage the bug > occurs. Good thinking, indeed the problem occured long before that. The main problem is "p=0", you probably want "p=(unsigned char xdata*)0" or this would never do what you expect :), but you insist on "p=0". Now the compiler sees "p[i]=0" and icode-s that as "*(p+i)=0" (iTemp3 in dumpdflow) in this example. Now the optimizer (knowing that p==0 and never changes later) says "*(0+i)" then "*i" (iTemp2 in dumpgcse) and then decides that i (replaced by iTemp8) MUST be a pointer (to an array or structure member) (in dumploopg). SDCCcse.c:1.77 fixes this, but doesn't "warn" anymore for this obvious error. HTH Johan |