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

Incorrect Asm in x64 FastStringBuilder Append for Char #5

Open
deadserious opened this issue Oct 13, 2018 · 1 comment
Open

Incorrect Asm in x64 FastStringBuilder Append for Char #5

deadserious opened this issue Oct 13, 2018 · 1 comment

Comments

@deadserious
Copy link

When using x64 compiler...

sb := TStringBuilder.Create;
sb.Append('{')
sb.Append('items:{}');
sb.Append('}');

sb.ToString does not result in the expected '{items:{}}' but instead
$01+'items:{}}'

If you comment out the asm and use the delphi native code, it is correct.

@JBontes
Copy link
Owner

JBontes commented Oct 15, 2018

Using Delphi Tokyo, I've added testcases for FastStringBuilder.TStringBuilder and I'm unable to confirm your findings both on x64 and x86. Can you pls download the lastest code, retry, and state which compiler you're using. I have Berlin as well. And with a bit of effort I may be able to test it on the older compilers.

Here's the testcode I used to try and confirm your case:

procedure TTestFastStringBuilder<T>.Setup;
begin
  FData:= TStringBuilder.Create;
end;

procedure TTestFastStringBuilder<T>.TearDown;
begin
  FData.Free;
end;

procedure TTestFastStringBuilder<T>.HardcodedSandwhich;
var
  s: string;
  c: char;
  norm: string;
begin
  s:= 'items:{}';
  FData.Append('{');
  if TypeInfo(T) = TypeInfo(char) then begin
    FData.Append('{');
    norm := '{' + '{' + '}';
  end else if TypeInfo(T) = TypeInfo(string) then begin
    FData.Append(s);
    norm := '{' + s + '}';
  end;
  FData.Append('}');
  Assert.IsTrue(FData.ToString = norm,'HardcodedSandwhich failed, expected: '+norm+' got: '+FData.ToString);
end;

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