View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0035066||FPC||Compiler||public||2019-02-12 19:20||2019-02-17 22:09|
|Reporter||helbig1||Assigned To||Joost van der Sluis|
|Status||closed||Resolution||no change required|
|Product Version||3.0.4||Product Build|
|Target Version||3.2.0||Fixed in Version||3.2.0|
|Summary||0035066: 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 Reproduce||Here is the source abs.p:|
$ cat abs.p
program mf(input, output);
halfword = 0 .. 65535;
glueratio = real;
quarterword = 0.. 255;
twochoices = 1 .. 2;
fourchoices = 1 .. 4;
twohalves = packed record
case twochoices of
1: (lh : halfword);
2: (bo: quarterword; b1 : quarterword);
fourquarters = packed record b0: quarterword;
memoryword = record
case fourchoices of
1: (int : integer);
2: (gr : glueratio);
3: (hh: twohalves);
4: (qqqq: fourquarters);
mw.hh.lh := 1000;
mw.hh.rh := 123;
writeln(abs(mw.hh.rh + mw.hh.lh - 1000));
|Additional Information||This is from Knuths TeX.|
Trying to build TeX and friends with fpc.
|Tags||No tags attached.|
|Fixed in Revision|
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.
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.
||Note that in 3.3.1 I did not need the cast. Trunk ( and 3.2.0 ) contain many ISO mode fixes.|
||Maybe do a little test and close as fixed in 3.2.0? As I recall Florian fixed this in 3.1.1.|
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.
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.
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.
||According to the reporter it has been fixed already.|
|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|