Hello,
I found the following bug in the Beta version of GPC.
Best regards, Peter Dietrich -------------------- GPC-Version (gpc -v):
Reading specs from C:\usr\local\lib\gcc-lib\i386-mingw32\2.8.1\specs gpc version 19990118, based on gcc-2.8.1
System-Version:
Windows NT 4.0 on i386
Problem description:
Variant records with tag fields cannot be initialized. The following program is not accepted by the compiler:
program test (output);
type t = record f1 : integer; case tag : integer of 0: (i : integer); 1: (r : real); end;
var r : t value (1, 1, 3.14); begin writeln (r.f1, r.tag, r.r); end.
The error message is:
test3.pas:10: incompatible types in initialization test3.pas:10: initial value is of wrong type
If I omit the 3.14 compilation succeeds but only f1 and tag are initialized.
Hallo, Peter!
I found the following bug in the Beta version of GPC.
Thanks for the detailed bug reports. They really help us getting rid of the bugs.
Variant records with tag fields cannot be initialized. The following program is not accepted by the compiler:
program test (output);
type t = record f1 : integer; case tag : integer of 0: (i : integer); 1: (r : real); end;
var r : t value (1, 1, 3.14);
Is this syntax compatible to any other compiler, or are we free to define this?
Peter
On 16 Jun 99, at 22:01, Peter Gerwinski wrote:
var r : t value (1, 1, 3.14);
Is this syntax compatible to any other compiler, or are we free to define this?
For ISO Extended Pascal, the required syntax appears to be:
var r : t value [f1:1; case tag:1 of [r:3.14]];
-or-
var r : t value [f1:1; case 1 of [r:3.14]];
if I read my EP standard correctly (the tag identifier appears to be optional).
-- Dave Bryan
Hello
BP wants
type t = record f1 : integer; case tag : integer of 0: (i : integer); 1: (r : real); end;
const r : t = (f1:1; tag:1; r:3.14);
i.e. ; instead of , (works also with gpc) field names (required in BP; GPC ignores them and issues a warning: GPC bug ...) BP does not control consistency between tag and variant field name: (f1:1; tag:1; i:3) works also !!! In fact the tag is just an other field which has no purpose as a discriminant. ... plus the stupid const instead of var for initialized variable an other use for --borland-pascal ? Hope this helps Maurice