[fpc-devel] Improper OUT usage.
Sven Barth
pascaldragon at googlemail.com
Mon Mar 11 07:07:02 CET 2013
Am 11.03.2013 02:31 schrieb "Flávio Etrusco" <flavio.etrusco at gmail.com>:
>
> On Sun, Mar 10, 2013 at 6:08 PM, Sven Barth <pascaldragon at googlemail.com>
wrote:
> > On 10.03.2013 20:39, Flávio Etrusco wrote:
> >>
> >> I'd really like the compiler would stop with an error if it can't
> >> prove a variable/out/result is initialized.
> >> Did anybody try implementing this in FPC?
> >
> >
> > Have fun fixing the errors then:
> >
> > === example begin ===
> >
> > type
> > TTest = record
> > t: LongInt;
> > end;
> > var
> > t: TTest;
> > begin
> > FillChar(t, SizeOf(t), 0);
> > end;
> >
> > === example end ===
> >
> > The above code will have the hint that "t" is not initalized.
> >
> > Regards,
> > Sven
>
> t.t := 0; // ;-)
I don't consider this a nice solution...
> This reminds me that a magic compiler procedure to zero-fill records
> without the sizeof parameter (and without the hint) has always been on
> my wishlist :-) (now I'll have to dig the message where sb explained
> why FillChar couldn't be declared with 'out' - IIRC something
> regarding interfaces)
In 2.7.1 (implemented for around three quarter of a year):
=== example begin ===
t := Default(TTest);
=== example end ===
Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20130311/d16c7ebd/attachment.html>
More information about the fpc-devel
mailing list