Skip to content

Only use Win64 vectorcall special case if calling convention is vectorcall.

Summary

Removes an incorrect Win64 calling convention special case for handling records with only one floating point field.

Only use Win64 vectorcall special case if calling convention is vectorcall.

System

  • Operating system: Windows
  • Processor architecture: x86-64
  • Device: N/A

What is the current bug behavior?

Passing records with only one floating point field on Win64 only works for vectorcall.

// test.pas
program test;

type
  rec1 = record
    onlyfield: Single;
  end;

  rec2 = record
    onlyfield: Double;
  end;

procedure fn(a1: rec1; a2: rec2); cdecl; external 'MyLib.dll';

var
  myrec1: rec1;
  myrec2: rec2;
begin
  myrec1.onlyfield := 1.0;
  myrec2.onlyfield := 2.0;
  fn(myrec1, myrec2);
end.
// MyLib.c
#include <stdio.h>

struct rec1 {
  float onlyfield;
};

struct rec2 {
  double onlyfield;
};

__declspec(dllexport) void fn(struct rec1 a1, struct rec2 a2) {
  printf("a1.onlyfield: %f\na2.onlyfield: %f\n", a1.onlyfield, a2.onlyfield);
}

Running:

cl /LD MyLib.c
fpc -Twin64 -Px86_64 test.pas
test

Will output:

a1.onlyfield: 0.000000
a2.onlyfield: 0.000000

What is the behavior after applying this patch?

The records are passed correctly regardless of calling convention. Running the same commands with the same code will output:

a1.onlyfield: 1.000000
a2.onlyfield: 2.000000

Relevant logs and/or screenshots

N/A

Edited by Brendan Dougherty

Merge request reports