[fpc-devel] Initialize/Finalize management operators and Default intrinsic

Florian Klämpfl florian at freepascal.org
Tue Apr 12 21:12:29 CEST 2016


Am 12.04.2016 um 08:57 schrieb Maciej Izak:
> 2016-04-11 23:36 GMT+02:00 Sven Barth <pascaldragon at googlemail.com
> <mailto:pascaldragon at googlemail.com>>:
> 
>     I know this is a rather constructed example, but it's similar to the C++
>     code we had at work, so it's code that can happen in the real world.
>     If we don't find a way to solve this problem then I'm afraid that I
>     won't include your changes in trunk, cause I don't want to open that can
>     of worms.
> 
> 
> Eeeee? I am a little shocked by your arguments because that kind of bug is possible since we have
> initialization/finalization section and uses section in interface/implementation section. *The
> programmer must be aware of*. The mentioned bugs are here a looong time. For example fixed by me for
> Lazarus:
> http://svn.freepascal.org/cgi-bin/viewvc.cgi?view=revision&root=lazarus&sortby=date&revision=49547
> 

I agree with Maciej here: this kind of stuff can also happen with normal initialization code and
uses of units in the implementation part. In this case the programmer must simply be very careful.
Though in your example I think unit1 is always initialized first as it does not depend on unit2. The
problem might pop up though if you use unit2 in the implementation part of unit1.




More information about the fpc-devel mailing list