Can we fix the old age problem with the [HighVaueConstant..LowValueConst] causing no code generation!
Original Reporter info from Mantis: jamie @jamie
-
Reporter name: jamie philbrook
Original Reporter info from Mantis: jamie @jamie
- Reporter name: jamie philbrook
Description:
If using a statement like this:
I := 0;
While Not (Somestring[I] in ['#'..#0]) Do Inc(I);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ gets left out in compile.
You end up with a
While true do inc(I); In code land which simply loops for ever!
Putting the "Not" in the statement causes the compiler to not create a
warning. It compiles with no errors and no warnings.
If I remove the "NOT", then the warning of CODE not reachable is generated
and it simply ignores looping forever and moves on.
This issue is the starting Value being higher than the ending value. It simply
refuses to generate code and only gives warning of this when not using a "NOT"
operator. The end results can lead to some very hard bugs to find.
So using Constants, even defined constants instead of immediate types will
generate this issue.
Lets say I use some constants instead of immediate ones, I set the values one
day and it works, I decide to change them around and get them backwards in order, but they are still in the range I need. The compiler will be happy to accept this but generates no code and bugs in your app with no warnings
Using variables, even if only one of them is a variable does process correctly for the range values even if they High to low order.
Is it that hard to simply have the compiler swap the constants so it'll be happy and actually generate the code?
Steps to reproduce:
Just create a [ConstantThatIsHigher..ConstThatIslower] in any form
of IF,WHILE , Repeat etc.
Run to code and step it with the debugger and assembler view
Mantis conversion info:
- Mantis ID: 31936
- OS: Windows
- OS Build: 10,
- Platform: Windows
- Fixed in version: 3.1.1
- Fixed in revision: 38321 (#d031545f)