[fpc-pascal] How to solve "variable does not seem to be
initialized" compiler hint.
graemeg.lists at gmail.com
Thu Nov 19 20:52:40 CET 2009
2009/11/19 "Vinzent Höfler" <JeLlyFish.software at gmx.net>:
>> Then create a different FillChar -type
>> procedure to handle those corner cases, or create a different procedure
>> which allows structure types to be initialized without compiler hints.
> Why don't you create your own initialization routine together with the
Because not all the code I maintain is my own. Some code, as in the
case of DCPCrypt gave stacks of hints which were all false positives.
If I now go around changing all these pieces of code, it will make it
harder to backport my actual fixes to the upstream DCPCrypt code.
DCPCrypt will be riddled with changes simply to stop FPC making such a
lot of noize at compile time - and those changes will not actually be
"fixes" for upstream repository.
> the general "initialization equals setting it to zero" approach (which
> I personally refer to as "paranoia initialization" - in practice it
A simple example where it is vital to initialize such structures. I'm
working on a IPF compiler (fpGUI + OS/2 help system compiler). It use
a ton of data structures right down to bit level. If those data
structures are not zero'ed out at initialization, this could have
disastrous effects further down the line when random data still
occupies those data structures.
So no, initializing data structures is nothing about "paranoia". It's
about knowing what the initial value is of a type or data structure
when it gets used.
- Graeme -
fpGUI - a cross-platform Free Pascal GUI toolkit
More information about the fpc-pascal