[fpc-devel] [Suggestion] Enumeration range-check intrinsic
Tony
afmcc at btinternet.com
Fri Jul 5 11:16:43 CEST 2019
On Fri, 5 Jul 2019 00:40:15 +0100
"J. Gareth Moreton" <gareth at moreton-family.com> wrote:
> You could consider this an ultimatum, but I know it will be pointless
> to do that because you'll just ignore me. So I'm pleading, Jonas...
> there needs to be a way to check if an enumeration contains an
> invalid value to avoid diving into the realm of undefined behaviour.
> Just because you wouldn't use it doesn't mean we won't.
I am only a hobbyist, so take this for what it's worth. I am very
puzzled by Gareth's insistence on this issue. It seems to me that, if
there is a chance that a value read from some external source might
have a value outside the range of an enum, then enum is not the right
data type for that operation. Use an appropriate integer type
instead.
Tony
More information about the fpc-devel
mailing list