The attached example, produces the following highly informative error message when compiled:
gpcbug20100502.p:13: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See URL:http://www.gnu-pascal.de/todo.html for instructions.
I'm running GPC 20070904, based on gcc-4.1.2 under 64-bit Linux (Slamd64 12.2 to be exact). The error is also triggered on my 32-bit Linux (Debian 5.0.4) system running the same compiler, based on gcc-4.1.3.
The code (attached) is as follows:
unit example; interface
type CandName(MaxCandName:integer) = string(MaxCandName); CandStatus = (Elected, Eliminated, Neither); CandRecord = record Name : CandName; RawVote : integer; Allocation : integer; Status : CandStatus; end; CandArray(N:integer) = array[1..N] of CandRecord; end.
If I change the declaration on the array to "^CandRecord", the example compiles normally. The types also compile normally inside of a program (instead of a unit).
If there's a more recent version of the GPC codebase that I should be using instead, then please let me know.
--------------------------| John L. Ries | Salford Systems | Phone: (619)543-8880 x107 | or (435)867-8885 | --------------------------|
Correction: Makes no difference if I compile the types inside a program (or a module), rather than a unit, but if I change the definition of CandName to use a constant length, rather than a schema, the crash goes away.
Example:
const MaxCandName = 30;
type CandName = string(MaxCandName);
Eliminates the crash. Obviously, I'd rather use the schema.
--------------------------| John L. Ries | Salford Systems | Phone: (619)543-8880 x107 | or (435)867-8885 | --------------------------|
On Sun, 2 May 2010, John L. Ries wrote:
The attached example, produces the following highly informative error message when compiled:
gpcbug20100502.p:13: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See URL:http://www.gnu-pascal.de/todo.html for instructions.
I'm running GPC 20070904, based on gcc-4.1.2 under 64-bit Linux (Slamd64 12.2 to be exact). The error is also triggered on my 32-bit Linux (Debian 5.0.4) system running the same compiler, based on gcc-4.1.3.
The code (attached) is as follows:
unit example; interface
type CandName(MaxCandName:integer) = string(MaxCandName); CandStatus = (Elected, Eliminated, Neither); CandRecord = record Name : CandName; RawVote : integer; Allocation : integer; Status : CandStatus; end; CandArray(N:integer) = array[1..N] of CandRecord; end.
If I change the declaration on the array to "^CandRecord", the example compiles normally. The types also compile normally inside of a program (instead of a unit).
If there's a more recent version of the GPC codebase that I should be using instead, then please let me know.
--------------------------| John L. Ries | Salford Systems | Phone: (619)543-8880 x107 | or (435)867-8885 | --------------------------|
John L. Ries a écrit :
The attached example, produces the following highly informative error message when compiled:
gpcbug20100502.p:13: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See URL:http://www.gnu-pascal.de/todo.html for instructions.
I'm running GPC 20070904, based on gcc-4.1.2 under 64-bit Linux (Slamd64 12.2 to be exact). The error is also triggered on my 32-bit Linux (Debian 5.0.4) system running the same compiler, based on gcc-4.1.3.
The code (attached) is as follows:
unit example; interface
type CandName(MaxCandName:integer) = string(MaxCandName); CandStatus = (Elected, Eliminated, Neither); CandRecord = record Name : CandName; RawVote : integer; Allocation : integer; Status : CandStatus; end; CandArray(N:integer) = array[1..N] of CandRecord; end.
If I change the declaration on the array to "^CandRecord", the example compiles normally. The types also compile normally inside of a program (instead of a unit).
If there's a more recent version of the GPC codebase that I should be using instead, then please let me know.
Same error here with MINGW / gpc20070904 / gcc3.4.5 no error with DJGPP / gcc 3.4.4 or 4.1.2 Hope this helps
Maurice
John L. Ries wrote:
Correction: Makes no difference if I compile the types inside a program (or a module), rather than a unit, but if I change the definition of CandName to use a constant length, rather than a schema, the crash goes away.
Example:
const MaxCandName = 30;
type CandName = string(MaxCandName);
Eliminates the crash. Obviously, I'd rather use the schema.
Of course, the compiler should not crash, but the code is incorrect, since the discriminant for the "Name" record field is missing. The following modification compiles (with my GPC version), though I didn't write a test program to see if it works correctly.
The point is, you need to specify the value at some place. Here I only shift this place outwards, to the record and then the array type. If you want it to be dynamic at runtime, you need a pointer ("^CandName") which you can allocate with "New (Name, Value)" (and later "Dispose", usually).
unit example; interface
type CandName(MaxCandName:integer) = string(MaxCandName); CandStatus = (Elected, Eliminated, Neither); CandRecord(MaxCandName:integer) = record Name : CandName(MaxCandName); RawVote : integer; Allocation : integer; Status : CandStatus; end; CandArray(N,MaxCandName:integer) = array[1..N] of CandRecord(MaxCandName); end.
Frank
Thanks you very much.
--------------------------| John L. Ries | Salford Systems | Phone: (619)543-8880 x107 | or (435)867-8885 | --------------------------|
On Tue, 4 May 2010, Frank Heckenbach wrote:
John L. Ries wrote:
Correction: Makes no difference if I compile the types inside a program (or a module), rather than a unit, but if I change the definition of CandName to use a constant length, rather than a schema, the crash goes away.
Example:
const MaxCandName = 30;
type CandName = string(MaxCandName);
Eliminates the crash. Obviously, I'd rather use the schema.
Of course, the compiler should not crash, but the code is incorrect, since the discriminant for the "Name" record field is missing. The following modification compiles (with my GPC version), though I didn't write a test program to see if it works correctly.
The point is, you need to specify the value at some place. Here I only shift this place outwards, to the record and then the array type. If you want it to be dynamic at runtime, you need a pointer ("^CandName") which you can allocate with "New (Name, Value)" (and later "Dispose", usually).
unit example; interface
type CandName(MaxCandName:integer) = string(MaxCandName); CandStatus = (Elected, Eliminated, Neither); CandRecord(MaxCandName:integer) = record Name : CandName(MaxCandName); RawVote : integer; Allocation : integer; Status : CandStatus; end; CandArray(N,MaxCandName:integer) = array[1..N] of CandRecord(MaxCandName); end.
Frank
-- Frank Heckenbach, f.heckenbach@fh-soft.de, http://fjf.gnu.de/, 7977168E GPC To-Do list, latest features, fixed bugs: http://www.gnu-pascal.de/todo.html GPC download signing key: ACB3 79B2 7EB2 B7A7 EFDE D101 CD02 4C9D 0FE0 E5E8