A recursive call of a function without arguments is not recognised as such.
Original Reporter info from Mantis: Feliks
-
Reporter name: Feliks Kluzniak
Original Reporter info from Mantis: Feliks
- Reporter name: Feliks Kluzniak
Description:
A function without arguments can contain its own name in an expression. This is tantamount to a recursive invocation. The compiler does not recognise it as such, and may produce an incorrect warning ("Function result variable does not seem to initialized").
The workaround is to add an unused argument to the function.
See the attached example.
Steps to reproduce:
See the attached example. The idea is to print the first character that is not a left parenthesis.
Compilation of file see.p produces a warning, and running the program does not give the right result when the input begins with a left parenthesis.
The program can be made to run by adding an unused argument to function "rd".
The example is a boiled-down version of a large real program which ran on many versions on Pascal, but mysteriously failed when ported to Free Pascal.
Mantis conversion info:
- Mantis ID: 24309
- Build: [2011/12/30] for i386
- Version: 2.6.0
- Fixed in version: 3.0.0
- Fixed in revision: 1013 (#4055d3f7)