On 06/07/2019 14:56, Martok wrote:
> Am 06.07.2019 um 09:01 schrieb Ondrej Pokorny:
>> Ord(aEnum) for invalid enumeration values is undefined ;)
> 
> If there was any logic here, it should be, but it's not ;-)
> 
> The documentation page specifically mentions Ord as the older syntax to hard
> casts. Whatever it contains, any enum is always smaller or equal to the 
> largest
> possible bitsize, which is Longint.

It is in fact undefined. The undefined behaviour comes from the fact
that an invalid value was stored in the variable and then read again,
not from how the read value is used. An example of where you may get
different data than wat you put in, even in the absence of any
optimisations, is again bitpacked records/arrays.


Jonas
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to