Adriaan van Os wrote:
In the Macintosh Pascal mailing list (http://pascal-central.com/maillist.html) Scott Lindhurst wrote:
I just started playing around with gpc, working on getting some old code to work with it, and have found a bug. This is version 3.3.2d1, just downloaded a few days ago with the accompanying GPCInterfacesB2, on OS X 10.2.8.
I get the message "gpc: Internal error: Illegal instruction (program gpc1)" when compiling the following program:
program bug;
uses GPCMacOSAll, GPCStringsAll; {No error if remove GPCStringsAll}
var tix: UInt32; {No error if change to integer or longint} begin tix := 1;
if tix > TickCount then {error while processing this line} tix := 2; end.
<snip>
but the internal error can be reproduced with just gpc --unit-path=/Developer/Pascal/GPCPInterfaces/ ./bug.pas
I have the workaround of using integer or longint instead of UInt32.
Peter N. Lewis helped out by noting that "limit stacksize 8096" solves the problem. This is true, but still it is strange that the compiler needs such a huge amount of stack for compilation. So, I wonder if maybe there is indeed a problem in the compiler, solved only "by accident" by a stacklimit of nearly a megabyte.
I fetched the units and tried on i386. Appearently, running on i386 Linux, the compiler needs 4272 kB (more then four megabytes) to compile the program. AFAIKS the file GPCMacOSAll defines more then 270 variants of the UInt32 type. In the function `get_operator' the compiler performs quadratic search for comparison operator (checking _all_ pairs of variants of UInt32 type). For each pairs of variants the compiler generates appropriate name for possible comparison operator and checks if it is present. The names are allocated on the stack and accumulate.
If looks easy to avoid accumulating names on the stack, but the quadratic search makes the compiler quite slow (at least with your types...).