View Issue Details

IDProjectCategoryView StatusLast Update
0035066FPCCompilerpublic2019-02-17 22:09
Reporterhelbig1Assigned ToJoost van der Sluis 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionno change required 
Product Version3.0.4Product Build 
Target Version3.2.0Fixed in Version3.2.0 
Summary0035066: fpc says "cannot determine which overloaded function to call"
Description$ fpc abs.p
abs.p(33,9) Error: Can't determine which overloaded function to call
abs.p(35) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: /usr/local/bin/ppcx64 returned an error exitcode
Steps To ReproduceHere is the source abs.p:
$ cat abs.p
{$MODE ISO}
program mf(input, output);
type
 halfword = 0 .. 65535;
glueratio = real;
quarterword = 0.. 255;
twochoices = 1 .. 2;
fourchoices = 1 .. 4;
twohalves = packed record
rh: halfword;
case twochoices of
1: (lh : halfword);
2: (bo: quarterword; b1 : quarterword);
end;
fourquarters = packed record b0: quarterword;
b1: quarterword;
b2: quarterword;
b3: quarterword;
end;
memoryword = record
case fourchoices of
1: (int : integer);
2: (gr : glueratio);
3: (hh: twohalves);
4: (qqqq: fourquarters);
end;
var
mw: memoryword;

begin
mw.hh.lh := 1000;
mw.hh.rh := 123;
writeln(abs(mw.hh.rh + mw.hh.lh - 1000));
end.
Additional InformationThis is from Knuths TeX.
Trying to build TeX and friends with fpc.
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget
Attached Files

Activities

jamie philbrook

2019-02-12 23:02

reporter   ~0114060

A lot of us here know what the problem is..

You can fix it by type casting around the equation for the ABS to a known
type you would expect.
 
 However, this issue does not exist in TP, and all the versions of Delphi
I have played with, these compilers will return the starting type on the left
as they should.

 In the background the compiler Is free to elevate this to a integer and perform
the complete equation. This is done for variables etc, however, in cases of doing this within a parameter for a function or procedure, the compiler knows there are two types, one that it started with and the other that it converted to and It for what ever reason can't make its mind up.

 All the other compilers I play with seems to know how to handle this, it picks
the type it started with on the left as the final resulting type. This makes
perfect sense since this also happens when assigning variables a value from a
compound statement, the compiler does not complain about that but it does here, hmmm.


 Good luck.

helbig

2019-02-16 07:39

reporter   ~0114166

With ISO Pascal there is no ambiguity about the result type of numeric expressions.
If all operands are integers, the type of the expression is integer. Otherwise, at least one of the operands is of type real and the resulting type will be real. In ISO Pascal the type of an expression is never a subrange type. It would be nice, if the ISO flag would turn on this behaviour.

The cast saved my day. TeX-FPC, as I call it, finally compiles! Thank you for the hint, Jamie.

Thaddy de Koning

2019-02-16 08:15

reporter   ~0114167

Note that in 3.3.1 I did not need the cast. Trunk ( and 3.2.0 ) contain many ISO mode fixes.

Thaddy de Koning

2019-02-16 17:21

reporter   ~0114189

Maybe do a little test and close as fixed in 3.2.0? As I recall Florian fixed this in 3.1.1.

helbig

2019-02-17 08:12

reporter   ~0114209

Last edited: 2019-02-17 13:07

View 2 revisions

Sorry, I am not a developer. I am only a mathematician. I can only prove correctness of a program, but i do not know how to test correctness of a program.

Thaddy de Koning

2019-02-17 13:50

reporter   ~0114215

Yes, but there are already downloads for 3.2.0 RC's available.
What I did was simply run your code on trunk and 3.2.0. That works without the cast.

helbig

2019-02-17 14:46

reporter   ~0114218

This issue can be closed on my behalf. By the way, the cast was not necessary at 3.0.2
So I hesitate to use 3.2.0. Other errors might be introduced. But thnaks again for the tip.

Joost van der Sluis

2019-02-17 22:09

manager   ~0114230

According to the reporter it has been fixed already.

Issue History

Date Modified Username Field Change
2019-02-12 19:20 helbig1 New Issue
2019-02-12 23:02 jamie philbrook Note Added: 0114060
2019-02-16 07:39 helbig Note Added: 0114166
2019-02-16 08:15 Thaddy de Koning Note Added: 0114167
2019-02-16 17:21 Thaddy de Koning Note Added: 0114189
2019-02-17 08:12 helbig Note Added: 0114209
2019-02-17 13:07 helbig Note Edited: 0114209 View Revisions
2019-02-17 13:50 Thaddy de Koning Note Added: 0114215
2019-02-17 14:46 helbig Note Added: 0114218
2019-02-17 22:09 Joost van der Sluis Note Added: 0114230
2019-02-17 22:09 Joost van der Sluis Status new => closed
2019-02-17 22:09 Joost van der Sluis Assigned To => Joost van der Sluis
2019-02-17 22:09 Joost van der Sluis Resolution open => no change required
2019-02-17 22:09 Joost van der Sluis Fixed in Version => 3.2.0
2019-02-17 22:09 Joost van der Sluis Target Version => 3.2.0