[fpc-pascal] Class constructor called unconditionally
Michael Van Canneyt
michael at freepascal.org
Thu Mar 31 16:28:08 CEST 2016
On Thu, 31 Mar 2016, silvioprog wrote:
> On Thu, Mar 31, 2016 at 10:58 AM, Vojtěch Čihák <vojtech.cihak at atlas.cz>
>> IMO compilers should be dogmatic otherwise one cannot rely on them. This
>> looks to me like advocating wrong optimization.
> Thanks for reply Vojtěch, but are you referring to Delphi or FPC
In general. You should never rely on such behaviour.
This is not very robust programming.
> I think that FPC should keep the Delphi class constructor behaviour in MODE
> DELPHI, allowing the programmers to port Delphi libraries to FPC, but ...
I suspect the problem is not in the mode, but in detecting whether a class is used
or not in a program. It becomes very complicated when you use e.g. run-time packages.
Delphi itself is buggy in this regard, and has been since at least D7.
For this reason, in general I advise against extensive use of initialization sections etc...
More information about the fpc-pascal