I for years used Delphi and not seen too many bugs as far as code generation, most of which were fixed..
But since I've started to use fpc & lazarus I have come to a conclusion that because one refuses to fix a
problem they know they have and decide to brush it off as a "This is a PASCAL language constraint" basically, which
is bullocks..
I ported various apps from Delphi that do a lot of work with Char.byte,WORD, DWORD QWORD due to their
nature in code..
-- This is what I have come up with that is problematic and clearly presented as real BUG that Delphi handles
correctly..
When ever you do any and I mean any enclosed math on a type that isn't an INTEGER it converts it to a integer in
the final results and thus also causes code generation to treat it as an integer; (THIS IS IN ERROR);
Example
HI(SOMEWORD+1); results in returning a WORD of a integer, not the high byte of the WORD, in other words, the
wrong HI function was called.
Now, do the same with creating two functions of your own OVERLOARD, and apply that same concept of math within, you'll get "CANT NOT DECIDE WHICH FUNCTION TO USE", now the compiler knows there is an issue here but
this time decides to tell you about it.. So FPC isn't totally stupid in this regard.
Now the latest...
Var
I, W:WORD;
Begin
W := $FFFF; // or even 0; does not matter;
For I := 0 to W-1 do; // you'll get a range error if on, otherwise, this will not execute at all.
Why? Because the action of W-1 as resulted in a integer results which means it is now range check issue and
of coruse that loop wont execute.
All of this can be fixed using a type cast around the math but do we need this?
This is not restricted to using constants , it also fails using variables as the operand.
However, The compiler understands this:
SomeWordTypeVariableSomeWhere := SomeOtherWordTypeVariable-1'; or what ever.
the compiler does not complain nor does it attempt to switch it an integer;
So why can't it so within the confines of parameters and loop control?
I am sure there are other areas, this is just a beginning.
maybe CODE TOOLS can somehow auto insert a typecast around those types of cases when they are encountered ?
This has been a thorn in my side for some time now since I have been converted apps over using FPC, I know this
isn't a FPC complete group but I have already given up on reporting this to the bug pages.
This is a classic example of a political brush off in my opinion
https://bugs.freepascal.org/view.php?id=33125Sorry for the rant but I felt it worth while