berg@cip-s07.informatik.rwth-aachen.de (AKA Solitair) (11/26/90)
Patches for TC++ v1.00 To fix the case statement. It behaved uncorrectly for unsigned ints bigger than 0x7fff. This error was in both the C and the C++ part, in both tcc.exe and tc.exe. Since I only needed tcc.exe for the project, I only have fixed that one; as a side effect, the recipe patch for the C++ part also works on tc.exe. To check if your compiler still has the bug, run the following program: ----------------------------------------------------------------------- #include <stdio.h> main(){unsigned i; i=0x4000;i<<=1; switch(i){ case 0x1000:i=1;break; case 0x2000:i=2;break; case 0x8000:i=3;break; case 0x4000:i=4;break;} printf("If %u!=3 then there definitely is a bug.\n",i);} ----------------------------------------------------------------------- The patch is as follows: offset: old new (only for tcc.exe, the command line version) 24595: 06 16 Fixes C compiler part. 24596: 9C 9A 24598: 7C 7E 2459A: 7F EB 35BB1: 8E EB Fixes C++ compiler part. 35BB2: 06 1A 35BBE: 46 56 35BBF: FC FA 35BC0: 7C 7E 35BC2: 75 EB 35BC3: 05 28 35BDD: 0E D7 35BE2: 09 D2 Or as a recipe (use this if the offsets, or values don't match exactly): (??= don't care; ..= old value; xx,yy,zz have to be copied) Find the following string in tcc.exe (C compiler part): 26 8b 45 04 26 8b 55 02 3b 06 ?? ?? 7c 0c 7f 06 3b 16 xx yy 76 04 33 ff eb 0e Substitute by: .. .. .. .. .. .. .. .. .. 16 xx yy 7e .. eb Find the following string in tcc.exe or tc.exe (C++ compiler part): 26 8b 3d 0b ff 74 18 8e 06 ?? ?? 26 8b 45 04 26 8b 55 02 3b 46 ?? 7c e1 75 05 3b 56 zz 72 da 0b ff 74 1f 8e 06 ?? ?? 26 8b 45 04 26 8b 55 02 3b 46 ?? 75 0e 3b 56 ?? 75 09 Substitute by: .. .. .. .. .. .. .. eb 1a .. .. .. .. .. .. .. .. .. .. .. 56 zz 7e .. eb 28 .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. d7 .. .. .. .. d2 -- Sincerely, berg%cip-s01.informatik.rwth-aachen.de@unido.bitnet Stephen R. van den Berg. "I code it in 5 min, optimize it in 90 min, because it's so well optimized: it runs in only 5 min. Actually, most of the time I optimize programs."