Hi -
We just got the latest version of gpc:
GNU Pascal version 19990118, based on gcc-2.8.1, compiled Aug 25 1999 09:07:02.
and it is objecting to a line of code in one of my programs:
ftp://ftp.ncifcrf.gov/pub/delila/makelogo.p
I am compiling with:
gpc makelogo.p -o makelogo
The message I get is:
makelogo.p: In function `Themain': makelogo.p:4093: cannot take address of bitfield `B'
Line 4093 is: readln(symvec,map[b].b, map[b].n);
b is defined as:
b: integer; (* index to a symbol *)
map is defined as:
position = 0..mapmax; place = packed record b: char; (* the symbol *) n: integer (* the number of symbols *) end;
so is it getting confused about the "two" uses of b?
I changed b to 'bloop' and made a new variable, but the other b was still around and it still yelled:
makelogo.p: In function `Themain': makelogo.p:4094: cannot take address of bitfield `B'
I even changed the definition so that:
readln(symvec,map[bloop].bsymbol, map[bloop].n);
but *STILL* got:
makelogo.p: In function `Themain': makelogo.p:4094: cannot take address of bitfield `Bsymbol'
since map is used in other places, there seems to be a bug in the use here in the middle of a readln.
So I defined
c: char;
and separated it;
readln(symvec,c, map[bloop].n); map[bloop].bsymbol := c;
and now it compiles.
This program compiles just fine with the Sun compiler and translates into C with p2c and compiles with gcc.
Regards,
Tom
Dr. Thomas D. Schneider National Cancer Institute Laboratory of Experimental and Computational Biology Frederick, Maryland 21702-1201 toms@ncifcrf.gov permanent email: toms@alum.mit.edu http://www.lecb.ncifcrf.gov/~toms/
Hello!
Tom Schneider wrote:
[...]
makelogo.p: In function `Themain': makelogo.p:4093: cannot take address of bitfield `B'
Line 4093 is: readln(symvec,map[b].b, map[b].n);
b is defined as:
b: integer; (* index to a symbol *)
map is defined as:
position = 0..mapmax; place = packed record b: char; (* the symbol *) n: integer (* the number of symbols *) end;
so is it getting confused about the "two" uses of b?
No, the problem is that `b' is a member of a *packed* record.
Normally, it is illegal to pass fields of packed records as `var' parameters. Anyway for `readln' the standard allows an exception, so you have indeed found a bug in GPC.
If you remove `packed' from the record's declaration the problem disappears. Alternatively, as you already know, you can use a temporary variable.
Hope this helps, and thanks for the report,
Peter