(General GPC questions should be address to the list gpc@gnu.de, where I'm forwarding this.)
please forgive my intrusion.
I am a complete noob to pascal but have been programming in other languages for over 20 years.
When I compile the following program with gpc (GNU Pascal version 20030507, based on gcc-3.3.1 (Mandrake Linux 9.2 3.3.1-2mdk), I get an error:
PROGRAM FOO; CONST IDLNGTH = 12; TYPE ALPHA = ARRAY [1..IDLNGTH] OF CHAR; ERIC = PACKED RECORD FRED1 : ALPHA; FRED2 : ALPHA; END; IDENTIFIER = PACKED RECORD NAME : ALPHA; NAME2 : ERIC; END; VAR FILID : IDENTIFIER ; I, J : INTEGER;
BEGIN J := 0 ; WITH FILID DO BEGIN WITH NAME2 DO BEGIN WRITELN('OK') END; END; END .
$ gpc FOO.pas FOO.pas: In main program: FOO.pas:22: error: cannot take address of packed record field `NAME2'
I read through the mail archive and came across this post: http://gnu-pascal.de/crystal/gpc/en/mail8737.html
Is this the same thing or am I missing something?
Yes, it's the one. The bug was fixed in gpc-20030830:
: 20030609: bug with arrays as fields of `packed' records (waldek6.pas)
I know that under 'C', you cannot take the address of a bitfield member but this seems a little excessive as all of the component parts are at least 1 byte and therefore should be addressable.
This isn't actually the reason. In Pascal, var parameter passing (and in GPC, by extension, also taking the address) of any packed fields is forbidden. But `with' isn't the same as taking the address (that's what was done incorrectly).
If this is the same thing, would you like me to forward the patch to Mandrake and try and persuade them to apply it?
I'd rather suggest to persuade them to upgrade to gpc-20030830 -- also for license issues (see http://gnu-pascal.de/crystal/gpc/en/mail9211.html).
Frank