[fpc-devel] [Suggestion] Enumeration range-check intrinsic

Ondrej Pokorny lazarus at kluug.net
Wed Jul 3 09:26:00 CEST 2019


On 02.07.2019 23:34, Jonas Maebe wrote:
> Invalid data means undefined behaviour, always. "is" is not a special
> case that is immune to this.

Don't you really see the need to handle invalid data with a /defined/ 
behavior? Enum and subrange types /can/ store invalid data and they /do/ 
store invalid data. Be it implicit assignments in object creation, 
clearing records with Default(TMyRecord), reading records from streams 
etc etc. The issue is here and it needs some solution. If you don't like 
"is" for this purpose, why not to introduce a compiler intrinsic 
Valid(MyValue) that would check if MyValue is within the allowed range 
of its type?

Or do you really think Valid(MyValue) should always return true and thus 
be replaced with the true constant at compile time?

Ondrej
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20190703/afadf347/attachment.html>


More information about the fpc-devel mailing list