Article View: comp.sys.transputer
Article #1665quirk in LSC
From: Scott Cannon
Date: Thu, 16 May 1991 14:54
Date: Thu, 16 May 1991 14:54
24 lines
1726 bytes
1726 bytes
Here's an interesting quirk of LSC 89.1 pointed out to me by a graduate student. Consider the following trivial program:
#include <stdlib.h>
#define N ...
main ()
{ int x[N];
printf (" success\n");
}
When N is defined as 1010 or more, the program runs fine. When N is defined as less than 970, the program runs fine. When N is define between 970 and 1010, the program produces garbage or hangs.
Since x is declared as local to main, it will be placed on the stack. With a default stack space of 4k, it is easy to see why an array size larger than 1000 would max out the run-time stack. What is confusing is why LARGER arrays seem to produce no problems! This example program is a simplification of a more complex program in which the quirk was first noticed. My guess is that a test is made concerning array allocations during compilation -- when an array is larger than stack space, it is moved to s
tatic memory or the default stacksize is increased. (Either that or example programs with large arrays have all been extremely lucky). Some feature of the test fails when the array size is nearly 4k or (int x[970]) to (int x[1010]).
Scott R. Cannon, PhD scott@cannon.cs.usu.edu
Dept. of Computer Science (801) 750-2015
Utah State Univ. FAX (801) 750-3378
Logan, UT. 84322-4205
Technical Details
Message-ID:
<9105161454.AA06109@cannon.cs.usu.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!ucsd!ucbvax!CANNON.CS.USU.EDU!scottShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!ucsd!ucbvax!CANNON.CS.USU.EDU!scott From: scott@CANNON.CS.USU.EDU (Scott Cannon) Newsgroups: comp.sys.transputer Subject: quirk in LSC Message-ID: <9105161454.AA06109@cannon.cs.usu.edu> Date: 16 May 91 14:54:51 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 18