View Issue Details

IDProjectCategoryView StatusLast Update
0035651FPCCompilerpublic2020-02-02 22:01
ReporterBenito van der Zander Assigned ToFlorian  
PrioritynormalSeverityminorReproducibilityhave not tried
Status resolvedResolutionno change required 
Product Version3.3.1 
Summary0035651: invalid mov size when reading byte followed by and not
DescriptionThis creates a 32-bit mov when it should create a 8-bit mov, on amd64

function getChar(source: pchar): integer;
000000000040114F 00 add %cl,0x7fe08307(%rbx)
result := (ord(source^) and not $80);
0000000000401150 8b07 mov (%rdi),%eax
0000000000401152 83e07f and $0x7f,%eax
0000000000401155 c3 retq
Steps To Reproduceprogram Project1;
{$mode objfpc}{$H+}

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

  s: string;
  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));
TagsNo tags attached.
Fixed in Revision
Attached Files


J. Gareth Moreton

2019-05-30 15:45

developer   ~0116462

i was going to say that I see nothing wrong with this, since Free Pascal expands intermediate expressions to the CPU size, but I see that it reads 4 bytes from %rdi. I'll check this one out a bit later to see what's going on.

Do-wan Kim

2019-05-31 07:49

reporter   ~0116466

It already fixed in "xor" related bug report. works fine on recent fpc trunk. Win32 and Win64 using 'movzbl' for byte access.


2020-02-02 22:01

administrator   ~0120854

Fixed meanwhile.

Issue History

Date Modified Username Field Change
2019-05-30 15:08 Benito van der Zander New Issue
2019-05-30 15:45 J. Gareth Moreton Note Added: 0116462
2019-05-31 07:49 Do-wan Kim Note Added: 0116466
2020-02-02 22:01 Florian Assigned To => Florian
2020-02-02 22:01 Florian Status new => resolved
2020-02-02 22:01 Florian Resolution open => no change required
2020-02-02 22:01 Florian FPCTarget => -
2020-02-02 22:01 Florian Note Added: 0120854