View Issue Details

IDProjectCategoryView StatusLast Update
0036556FPCCompilerpublic2020-01-15 07:32
ReporterMarģersAssigned To 
PrioritynormalSeverityminorReproducibilityhave not tried
Status newResolutionopen 
Platformx86_64OSlinuxOS Version.
Product Version3.3.1Product Build 
Target VersionFixed in Version 
Summary0036556: internal error 200309201 assembler function
Descriptionempty assembler function with parameter
Steps To Reproduceprogram internal_error_200309201;

function zunn ( a : qword): qword; assembler;
asm
    { mov rax, a}
end;

begin
end.
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget
Attached Files
  • int_er00.pas (161 bytes)
    program internal_error_200309201;
    
    type oWord = record q1, q2 : qword; end;
    
    function zunn ( a : oWord): oWord;  assembler;
    asm
         mov rax, a
    end;
    
    begin
    end.
    
    int_er00.pas (161 bytes)

Activities

Marco van de Voort

2020-01-11 19:23

manager   ~0120335

Compiling on win64 is ok.

Marģers

2020-01-11 19:24

reporter   ~0120336

updated example to fail

int_er00.pas (161 bytes)
program internal_error_200309201;

type oWord = record q1, q2 : qword; end;

function zunn ( a : oWord): oWord;  assembler;
asm
     mov rax, a
end;

begin
end.
int_er00.pas (161 bytes)

Marģers

2020-01-11 19:52

reporter   ~0120338

sorry, that initially i added example that does not produce internal error. But i found that textmode ide, once fall into internal error, never recovers and continue report internal error on perfectly fine code.

Thaddy de Koning

2020-01-14 19:35

reporter   ~0120446

rax can never hold oWord, which is twice the size. Furthermore the second example has no alignment specified: should be packed. So the code is not perfectly fine.
It should not throw the internal error, though. So it is a bug.

Marco van de Voort

2020-01-14 20:02

manager   ~0120448

Are you a bot? Which Oword ?

J. Gareth Moreton

2020-01-14 22:58

developer   ~0120450

Example code provided doesn't match the description of the issue. Issue reports that the following produces an internal error:

----

program internal_error_200309201;

function zunn ( a : qword): qword; assembler;
asm
end;

begin
end.

----

But the file says that the following raises an internal error instead:

----

program internal_error_200309201;

type oWord = record q1, q2 : qword; end;

function zunn ( a : oWord): oWord; assembler;
asm
     mov rax, a
end;

begin
end.

----

Which one causes the internal error? Granted, the file should raise a compiler error since 'a' is not a compatible type to be stored in a 64-bit register (should be a.q1 or a.q2 instead).

Need clarity. Is it the incompatible type or the empty assembler routine that causes the internal error?

Marco van de Voort

2020-01-14 23:58

manager   ~0120451

The oword one gives 200309201 on win64, but only when -a is given. Without -a it compiles (which might be a bug in itself)

J. Gareth Moreton

2020-01-15 00:11

developer   ~0120452

That does sound like a bug, since "a" is an incompatible type, or at the very least is not a 64-bit ordinal type and hence can't be cleanly written to RAX or any other 64-bit register. If it was a.q1 or a.q2 being written, then that's no problem.

I can't remember how such a record parameter is passed under x86_64-win64, whether it's by reference or stored in the lower half of XMM0.

Marģers

2020-01-15 07:06

reporter   ~0120455

Last edited: 2020-01-15 07:10

View 4 revisions

parameter "a" is passed as RSI:RDI on linux 64 bit (win64 it should be RDX:RCX )

MOV RAX, a.q1 or MOV RAX,a.q2 does not work ether: Cannot directly access fields of pointer-based parameters.

MOV RAX, qword ptr a
LEA RAX, a
MOV XMM0, a
those as well fall into internal error.

Sven Barth

2020-01-15 07:32

manager   ~0120457

FYI: On x86_64-win64 it's passed as a reference in RCX. The SSE registers are only used for floating points and the Win64 ABI does not do combined registers for parameter passing.

Issue History

Date Modified Username Field Change
2020-01-11 19:16 Marģers New Issue
2020-01-11 19:23 Marco van de Voort Note Added: 0120335
2020-01-11 19:24 Marģers File Added: int_er00.pas
2020-01-11 19:24 Marģers Note Added: 0120336
2020-01-11 19:52 Marģers Note Added: 0120338
2020-01-14 19:35 Thaddy de Koning Note Added: 0120446
2020-01-14 20:02 Marco van de Voort Note Added: 0120448
2020-01-14 22:58 J. Gareth Moreton Note Added: 0120450
2020-01-14 23:58 Marco van de Voort Note Added: 0120451
2020-01-15 00:11 J. Gareth Moreton Note Added: 0120452
2020-01-15 07:06 Marģers Note Added: 0120455
2020-01-15 07:07 Marģers Note Edited: 0120455 View Revisions
2020-01-15 07:07 Marģers Note Edited: 0120455 View Revisions
2020-01-15 07:10 Marģers Note Edited: 0120455 View Revisions
2020-01-15 07:32 Sven Barth Note Added: 0120457