hkr@mcshh.hanse.de (Holger Kruse) (05/19/91)
I think I found a serious bug in SAS C 5.10a and some earlier versions. I reported the bug to SAS a month ago but have not got any answer yet. According to the manual, the size of a single subscript of an array may be larger than 32767 if long (32-bit) integers are used, this means that a declaration like int far a[2][40000]; is valid, if long integers are used. The compiler produces incorrect code, if the size of the second subscript is larger than 32767 and if the first subscript is indexed by a variable less than 32 bits long. Example: char far a[3][34000]; main() { short c=2; /*or: char c=2; */ a[c][0]=0; } After compiling ("LC filename") "OMD" produces the following disassembly: ... | 0002 7E02 MOVEQ #02,D7 | 0004 2007 MOVE.L D7,D0 \ this calculates a | 0006 C1FC 84D0 MULS.W #84D0,D0 / NEGATIVE offset !!! | 000A 41F9 0000 0000-01 LEA 01.00000000,A0 | 0010 D1C0 ADDA.L D0,A0 | 0012 4210 CLR.B (A0) ... Changing the assignment "a[c][0]=0" to "a[(long)c][0]=0" leads to a correct compilation result: ... | 0002 7E02 MOVEQ #02,D7 | 0004 2007 MOVE.L D7,D0 \ | 0006 48C0 EXT.L D0 \ this is OK | 0008 223C 0000 84D0 MOVE.L #000084D0,D1 / | 000E 4EBA 0000-XX.1 JSR __CXM33(PC) / | 0012 41F9 0000 0000-01 LEA 01.00000000,A0 | 0018 D1C0 ADDA.L D0,A0 | 001A 4210 CLR.B (A0) ... I could understand if SAS C reported an error in the above case, but there is no error message or warning. You simply get a GURU when you run the compiled program. Or maybe I am wrong and what I am doing is illegal in C ? Btw, the Unix TeX package contains lots of declarations like the above. So if you try to compile it on an Amiga, better be careful... Holger Kruse -------------------------------------+---------------------------------- Holger Kruse ! German BTX: 040526128800-0001 Zwijndrechtring 50, 2000 Norderstedt ! INTERNET: hkr@mcshh.hanse.de Germany Phone: +49 40 5261288 ! UUCP: uunet!mcshh.hanse.de!hkr
hessmann@hal.fmi.uni-passau.de (Georg Hessmann) (05/21/91)
In article <9195@mcshh.hanse.de> hkr@mcshh.hanse.de (Holger Kruse) writes: | |I think I found a serious bug in SAS C 5.10a and some earlier versions. |I reported the bug to SAS a month ago but have not got any answer yet. I've reported this bug two month ago, same result :-) |According to the manual, the size of a single subscript of an array may be |larger than 32767 if long (32-bit) integers are used, this means that a |declaration like | int far a[2][40000]; |is valid, if long integers are used. | |The compiler produces incorrect code, if the size of the second subscript |is larger than 32767 and if the first subscript is indexed by a variable |less than 32 bits long. [description of the bug deleted] |I could understand if SAS C reported an error in the above |case, but there is no error message or warning. You simply get a GURU |when you run the compiled program. | |Or maybe I am wrong and what I am doing is illegal in C ? | |Btw, the Unix TeX package contains lots of declarations like the above. |So if you try to compile it on an Amiga, better be careful... That's the reason, why there exists no bigTeX version of PasTeX. :-(( |Holger Kruse Georg. -- hessmann@unipas.fmi.uni-passau.de hessmann@unipas.uucp