[fpc-devel] SizeOf( const typcasted as shortstring)
Sven Barth
pascaldragon at googlemail.com
Mon Aug 13 11:23:51 CEST 2018
Dmitry Boyarintsev <skalogryz.lists at gmail.com> schrieb am Mo., 13. Aug.
2018, 00:12:
> On Sun, Aug 12, 2018 at 5:40 PM Bart <bartjunk64 at gmail.com> wrote:
>
>> const
>> x = ShortString('abc');
>> begin
>> writeln(SizeOf(x));
>> end.
>>
>> Delphi (7) prints 256, fpc prints 3.
>>
>> Is that a bug or an implementation detail?
>>
>
> Implementation detail.
> And it seems to be wrong on Delphi size, because for reason it assigns a
> type to a (non-typed) constant.
> It would make sense to return 256, if the constant was declared like this:
> const
> x : ShortString = 'abc';
> and fpc does recognize such typed constant as 256 in size.
>
> It's odd that such expression compiles w/o any warnings or notes. (i.e.
> "ignoring typecasting for constant value expressions")
>
Support for typecasts in untyped constants is by design and sometimes
required, e.g. for unsigned 64-Bit values.
Regards,
Sven
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20180813/6f32f69c/attachment.html>
More information about the fpc-devel
mailing list