Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arithmetic on pointer passed by variable should not affect data #100

Closed
SignumTemporis opened this issue Apr 28, 2022 · 2 comments
Closed

Comments

@SignumTemporis
Copy link

SignumTemporis commented Apr 28, 2022

Issue description

Arithmetic on a pointer passed by variable modifies the data it refers to while it should effect the pointer itself.

For FPC -MDelphi v3.2.2 it works as expected.

Mad-Pascal Compiler version 9cc0813
Mad-Assembler version 40bfd80

Code to reproduce the issue

uses crt;

type BytePtr = ^Byte;

var
  data: array [0 .. 1] of Byte;
  p: BytePtr;

procedure DoSomething(var p2: Pointer);
begin
  p2 := p2 + 1;
end;

begin
  data[0] := 10;  data[1] := 20;

  p := @data;
  Write(p^);
  DoSomething(p);
  WriteLn(' ', p^);

  ReadKey();
end.

Output

Expected

10 20

Actual

10 11
@SignumTemporis SignumTemporis changed the title Operation on pointer passed by variable should not affect data Arithmetic on pointer passed by variable should not affect data Apr 28, 2022
@tebe6502
Copy link
Owner

@SignumTemporis
Copy link
Author

Works for me now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants