Skip to content
GitLab
    • GitLab: the DevOps platform
    • Explore GitLab
    • Install GitLab
    • How GitLab compares
    • Get started
    • GitLab docs
    • GitLab Learn
  • Pricing
  • Talk to an expert
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
    Projects Groups Topics Snippets
  • Register
  • Sign in
  • FPC Source FPC Source
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
    • Locked files
  • Issues 1,395
    • Issues 1,395
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 66
    • Merge requests 66
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test cases
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • FPC
  • FPCFPC
  • FPC SourceFPC Source
  • Issues
  • #39908
Closed
Open
Issue created Sep 17, 2022 by Okoba@OkobaPatino

Changing a value in an inline routine

Summary

Compiler lets the value change if the routine and the caller of it are both inline.

System Information

Lazarus 2.3.0 (rev main-2_3-1764-ge7f787f78d) FPC 3.3.1 x86_64-win64-win32/win64

Example Project

program project1;

  procedure Test1Inner(V: Integer); inline;
  begin
    V := 0;
  end;

  procedure Test1; inline;
  var
    V: Integer;
  begin
    V := 1;
    WriteLn('Before: ', V); //1
    Test1Inner(V);
    WriteLn('After: ', V); //0
  end;

  procedure Test2Inner(V: Integer);
  begin
    V := 0;
  end;

  procedure Test2; inline;
  var
    V: Integer;
  begin
    V := 1;
    WriteLn('Before: ', V); //1
    Test2Inner(V);
    WriteLn('After: ', V); //1
  end;

  procedure Test3Inner(V: Integer); inline;
  begin
    V := 0;
  end;

  procedure Test3;
  var
    V: Integer;
  begin
    V := 1;
    WriteLn('Before: ', V); //1
    Test3Inner(V);
    WriteLn('After: ', V); //1
  end;

begin
  Test1;
  Test2;
  Test3;
  ReadLn;
end.

What is the current bug behavior?

In Test1, the value will change.

What is the expected (correct) behavior?

Like Test2 and Test3, the value must not change.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking