[fpc-devel] Dangerous optimization in CASE..OF

Jonas Maebe jonas at freepascal.org
Sat Jul 15 21:39:18 CEST 2017


On 15/07/17 21:33, lazarus at kluug.net wrote:
> Am Sa., Jul. 15, 2017 21:07 schrieb Jonas Maebe <jonas at freepascal.org>:
> 
>     I have said from the start that it is possible to store invalid values
>     in variables through the use of a.o. pointers (which is what the class
>     zeroing does), explicit typecasts and assembly.
> 
> In this case you must not restrict us to work with invalid values in a 
> deterministic way.

You can if you always use explicit typecasts to different types and 
access everything through pointers and assembly. But then the question 
is why you want to use a restrictive type in the first place.

Either you declare a type as only holding a limited set of data when 
valid and assume it behaves as such, or you don't. A mixture is the 
worst of both worlds: no type safety and unexpected behaviour when 
something else assumes the type declaration actually means what is written.


Jonas



More information about the fpc-devel mailing list