<p>Am 11.03.2013 02:31 schrieb "Flávio Etrusco" <<a href="mailto:flavio.etrusco@gmail.com">flavio.etrusco@gmail.com</a>>:<br>
><br>
> On Sun, Mar 10, 2013 at 6:08 PM, Sven Barth <<a href="mailto:pascaldragon@googlemail.com">pascaldragon@googlemail.com</a>> wrote:<br>
> > On 10.03.2013 20:39, Flávio Etrusco wrote:<br>
> >><br>
> >> I'd really like the compiler would stop with an error if it can't<br>
> >> prove a variable/out/result is initialized.<br>
> >> Did anybody try implementing this in FPC?<br>
> ><br>
> ><br>
> > Have fun fixing the errors then:<br>
> ><br>
> > === example begin ===<br>
> ><br>
> > type<br>
> > TTest = record<br>
> > t: LongInt;<br>
> > end;<br>
> > var<br>
> > t: TTest;<br>
> > begin<br>
> > FillChar(t, SizeOf(t), 0);<br>
> > end;<br>
> ><br>
> > === example end ===<br>
> ><br>
> > The above code will have the hint that "t" is not initalized.<br>
> ><br>
> > Regards,<br>
> > Sven<br>
><br>
> t.t := 0; // ;-)</p>
<p>I don't consider this a nice solution...</p>
<p>> This reminds me that a magic compiler procedure to zero-fill records<br>
> without the sizeof parameter (and without the hint) has always been on<br>
> my wishlist :-) (now I'll have to dig the message where sb explained<br>
> why FillChar couldn't be declared with 'out' - IIRC something<br>
> regarding interfaces)</p>
<p>In 2.7.1 (implemented for around three quarter of a year):</p>
<p>=== example begin ===</p>
<p>t := Default(TTest);</p>
<p>=== example end ===</p>
<p>Regards,<br>
Sven</p>