On 17 Feb 2013 at 9:46, Adriaan van Os wrote:
Thomas Schneider wrote:
I discovered a program that crashes the GPC compiler, attached.
It doesn't crash the compiler on Mac OS X, but it does cause a runtime error, because you are overflowing the stack.
procedure writeprism(var dianalysis: text; dataprism: trisquare);
Ough. You are passing a very large datastructure as value parameter, which implies that a copy of it is put on the stack. This costs a huge amount of stack and a lot of time. Instead, try
procedure writeprism(var dianalysis: text; var dataprism: trisquare);
procedure themain(var da: text); var dataprism: trisquare; (* the data structure for diana *)
It is a local variable of main, therefore it lives on the stack. Instead, try
var dataprism: trisquare; (* the data structure for diana *)
procedure themain(var da: text);
(a rare case where the use global variables is advised).
It is a very large data structure (about 490mb). It doesn't make a lot of sense to have a static variable of that size. It is probably better to use a pointer. That way, it can be a local variable:
procedure themain(var da: text); var dataprism: ^trisquare; (* the data structure for diana *)
But I guess that the real issue here is the compiler crash that the OP gets. I can't reproduce the compiler crash, and neither can Adriaan. Can anyone else reproduce it?
Perhaps the OP can provide more details for those who are maintaining the compiler (e.g., what OS, what gpc version, etc?).
Best regards, The Chief -------- Prof. Abimbola A. Olowofoyeku (The African Chief) web: http://www.greatchief.plus.com/