[fpc-pascal] New Warnings with fpc >= 3.2.0

Sven Barth pascaldragon at googlemail.com
Wed Mar 11 14:25:28 CET 2020


fredvs via fpc-pascal <fpc-pascal at lists.freepascal.org> schrieb am Mi., 11.
März 2020, 12:51:

>
> Other question relative to Warnings:
>
> How to do this:
>
> tdataevent(de_afterapplyupdate)
>
> where TDataEvent is defined as
>
>  TDataEvent = (deFieldChange, deRecordChange, deDataSetChange,
>     deDataSetScroll, deLayoutChange, deUpdateRecord, deUpdateState,
>     deCheckBrowseMode, dePropertyChange, deFieldListChange, deFocusControl,
>     deParentScroll,deConnectChange,deReconcileError,deDisabledStateChange);
>
> and de_afterapplyupdate was defined with:
>
> const
> ...
>  de_afterapplyupdate = ord(high(tdataevent))+6;
>
> ________________
>
> Now:
>
> --->  tdataevent(de_afterapplyupdate)
>
> Gives as Warning:
>
> "msebufdataset.pas(4070,16) Warning: range check error while evaluating
> constants (20 must be between 0 and 14)"
>
> ?
>

You are abusing enums. Either use them correctly or not at all. With your
code you're moving outside of what is defined for the language (aka
"undefined behaviour") and thus you can expect misbehavior.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20200311/59969989/attachment-0001.html>


More information about the fpc-pascal mailing list