Russell Whitaker wrote:
I suppose this is a back-end bug, reproducible on other platforms.
I can not reproduce this on Amd64 Linux (tried verious option incuding -fPIC). I will try i386 Linux, but it looks that the program uses features that Apple decided to implement in its own way.
On linux i686, compiles & runs ok.
Thanks for trying this out on other platforms. Looking into this further, the cause seems to be a curious miscalculation of record sizes.
program prog;
type pv1 = record x, y: Extended; v: array[1..2] of Boolean; end; pv2 = packed record x, y: Extended; v: array[1..2] of Boolean; end; pv3 = record x, y: Extended; end; pv4 = packed record x, y: Extended; end; pv5 = record v: array[1..2] of Boolean; end; pv6 = packed record v: array[1..2] of Boolean; end;
procedure dcp; var sp: pv1; z: Boolean;
procedure d(p: pv1); begin writeln('access z before'); if z then writeln('z is true'); end;
begin { dcp } z := True; d(sp); end;
begin writeln( 'sizeof(pv1) = ', sizeof( pv1)); writeln( 'sizeof(pv2) = ', sizeof( pv2)); writeln( 'sizeof(pv3) = ', sizeof( pv3)); writeln( 'sizeof(pv4) = ', sizeof( pv4)); writeln( 'sizeof(pv5) = ', sizeof( pv5)); writeln( 'sizeof(pv6) = ', sizeof( pv6)); dcp; end.
[p17:~/gpc/testgpc/adriaan] adriaan% gpc schorn2.pas -Os [p17:~/gpc/testgpc/adriaan] adriaan% ./a.out sizeof(pv1) = 48 sizeof(pv2) = 34 sizeof(pv3) = 32 sizeof(pv4) = 32 sizeof(pv5) = 2 sizeof(pv6) = 2 access z before Bus error
Any hint where about to look in the back-end sources ?
Regards,
Adriaan van Os