[fpc-devel] [Suggestion] Enumeration range-check intrinsic
Michael Van Canneyt
michael at freepascal.org
Sat Jul 6 11:01:40 CEST 2019
On Sat, 6 Jul 2019, Ondrej Pokorny wrote:
> On 05.07.2019 22:44, J. Gareth Moreton wrote:
>>
>> In the meantime, I've extended your AS/IS patch over here
>> <https://bugs.freepascal.org/view.php?id=33603> to create efficient code
>> for x86 platforms, although currently it only does a range check and won't
>> correctly handle enumerations with holes. If non-contiguous enumerations
>> are going to be allowed, we'll need to design an algorithm that can cover
>> these holes with the smallest number of Boolean conditions.
>>
> IMO handling holes in enumerations is just a pure waste of time and energy.
> Delphi documents them as valid and the FPC compiler handles them as valid as
> well. IMO it is just an unnecessary extra added limitation to disable IS/AS
> on them. Furthermore they are used mainly for very specific needs, so are
> very marginal. The effort to make this work just doesn't pay off.
After considering what Ondrej pointed out about the behaviour of FPC and
delphi, I agree that checking lower and upper bounds should be sufficient.
Michael.
More information about the fpc-devel
mailing list