Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
  • Sign in / Register
  • FPC Source FPC Source
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 1,281
    • Issues 1,281
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 56
    • Merge requests 56
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Packages & Registries
    • Packages & 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
  • #35651
Closed
Open
Created May 30, 2019 by FPC Admin account@fpc_adminOwner

invalid mov size when reading byte followed by and not

Original Reporter info from Mantis: BeniBela @benibela
  • Reporter name: Benito van der Zander

Description:

This creates a 32-bit mov when it should create a 8-bit mov, on amd64

function getChar(source: pchar): integer;
begin
000000000040114F 00 add %cl,0x7fe08307(%rbx)
result := (ord(source^) and not $80);
0000000000401150 8b07 mov (%rdi),%eax
0000000000401152 83e07f and $0x7f,%eax
end;
0000000000401155 c3 retq

Steps to reproduce:

program Project1;
{$mode objfpc}{$H+}

function getChar(source: pchar): integer;
begin
  result := (ord(source^) and not $80);
end;

var
  s: string;
begin
  setlength(s, 100); //create a large string on heap, so valgrind actually gives an error
  s[100] := 'a';
  writeln(getChar(pchar(s)+length(s) - 1));
end.

Mantis conversion info:

  • Mantis ID: 35651
  • OS: linux
  • OS Build: opensuse
  • Build: r40721
  • Platform: amd64
  • Version: 3.3.1
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking