scott@ksuvax1.cis.ksu.edu (Scott Hammond) (07/11/88)
The AT&T C Compiler Issue 3.1 [presumed through] 4.1 and 4.2 (current) generates incorrect code when passing a structure as an argument whose size is 4k or greater. On both AT&T 3b2/400 (Issue 4.1 of C) and AT&T 3b15 (Issue 3.1 of C) the code produced gives an incorrect value to the argument pointer. The 3b2 version runs but the called function cannot see the proper arguments; the 3b15 version dumps core. Repeat by creating a two structures with a single character array in each. Make one 4k or greater in size (sizeof) and one whose sizeof is less than 4k (watch out for rounding to word boundaries). Place something in each string. Call a function, pass a struct and try to print the string (do two). Compile with cc -S to get assembly output. Observe in the two "calls" that the argument which affects the argument pointer is negative for the function with the 4k or greater struct. According to AT&T hotline the bug persists in version 4.2 and will be fixed next time around. For those of you thinking "how inefficent, why not pass a pointer?", we first discovered the bug when using Distributed Concurrent C (AT&T Bell Labs) and cannot depend on shared memory between processes. -- Ed Vopata, Scott Hammond -------- Scott Hammond Dept of Computing & Information Sciences scott@harris.cis.ksu.edu Kansas State University scott@ksuvax1.BITNET Manhattan, Kansas {pyramid,ucsd}!ncr-sd!ncrwic!ksuvax1!scott (913) 532-6350