Bad code is generated for "for" clauses if range variables are involved.
Original Reporter info from Mantis: Feliks
-
Reporter name: Feliks Kluzniak
Original Reporter info from Mantis: Feliks
- Reporter name: Feliks Kluzniak
Description:
Given variables "high", "low" and "ttop", all of the same integer range type, the loop beginning with
"for high := low to ttop - 1 do"
iterates even when "low" is initially greater than "ttop - 1".
Looks as if unsigned arithmetic is used, incorrectly.
The same behaviour is observed in several modes: FPC, TP, ISO.
Steps to reproduce:
See the attached file. The body of the loop should not be entered at all, instead the iterations go on and on...
This is extracted from a larger program that was written in 1983 and ran with several implementations of the original "Wirth/Jensen" Pascal, then with Turbo Pascal and some others. With Free Pascal it fails.
Mantis conversion info:
- Mantis ID: 24318
- OS: Mac OS X
- OS Build: 10.8.3
- Build: [2011/12/30] for i386
- Platform: MacBook Pro
- Version: 2.6.0
- Fixed in version: 3.1.1
- Fixed in revision: 37934 (#a2217ced)