[fpc-devel] Improper OUT usage.

Flávio Etrusco flavio.etrusco at gmail.com
Tue Mar 12 07:56:34 CET 2013


On Mon, Mar 11, 2013 at 3:07 AM, Sven Barth <pascaldragon at googlemail.com> wrote:
> 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:
>> > (...)
>> >   TTest = record
>> >     t: LongInt;
>> >   end;
>> > var
>> >   t: TTest;
>> > begin
>> >   FillChar(t, SizeOf(t), 0);
>> > 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...

I don't either ;-)
Of course the check would need a switch, I don't intend to change the
whole Pascal code base...
My post was indeed about getting some more persperctive about the
roadblockers - WRT both application and implementation - but I decide
it was too big and "cleaned" a bit too much :-$


>> 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

Great! Almost fantastic :-)
Looking forward for the 2.8 release.

Best regards,
Flávio



More information about the fpc-devel mailing list