Varying with statement reference for objects in mac-pascal mode
Original Reporter info from Mantis: Adriaan van Os
-
Reporter name: Adriaan van Os
Original Reporter info from Mantis: Adriaan van Os
- Reporter name: Adriaan van Os
Description:
Consider the following test program
{$ifdef FPC}
{$mode macpas}
{$endif}
program withtest1;
type rec = record i: integer end;
var r: rec; p: ^rec;
begin
r.i:=1;
p:= @r;
with p^ do
begin
p:=nil;
writeln( i)
end
end.
Compiled with FPC, this produces output "1". This is in accordance with section 6.8.3.10 of the ISO 7185:1990 Pascal standard, which states:
"The record-variable shall be accessed before the statement of the with-statement is executed, and
that access shall establish a reference to the variable during the entire execution of the statement of
the with-statement."
{$ifdef FPC}
{$mode macpas}
{$endif}
{$ifdef __GPC__}
{$mac-objects}
{$endif}
program withtest2;
type obj = object i: integer end;
var p, q, r: obj;
begin
new( p);
new( q);
p.i:= 1;
q.i:= 2;
r:= p;
with r do
begin
r:=q;
writeln( i)
end
end.
If we do the same with macpas style objects (that are implicit references), the FPC compiled program outputs "2", where the GPC and CodeWarrior compiled programs output "1". The FPC output violates the ISO defined behaviour of the with statement.
Additional information:
URL: http://svn.freepascal.org/svn/fpc/trunk
Repository Root: http://svn.freepascal.org/svn/fpc
Revision: 12745
Mantis conversion info:
- Mantis ID: 13210
- Version: 2.3.1
- Fixed in version: 2.4.0
- Fixed in revision: 12753 (#3dd32daa)
- Target version: 2.4.0