[fpc-devel] Dangerous optimization in CASE..OF
Ondrej Pokorny
lazarus at kluug.net
Fri Jul 14 20:21:39 CEST 2017
On 02.07.2017 22:02, Florian Klämpfl wrote:
> Am 02.07.2017 um 21:40 schrieb Martok:
>> Honestly, I still don't understand why we're even having this
>> discussion.
> Because it is a fundamental question: if there is any defined behavior
> possible if a variable
> contains an invalid value. I consider a value outside of the declared
> range as invalid, if it shall
> be valid, change the declaration of the type.
In this case, please fix the compiler so that it doesn't generate
invalid values by default:
program Project1;
{$mode objfpc}{$H+}
type
TMyEnum = (one = 1, two);
TMyClass = class
public
Enum: TMyEnum;
end;
var
O: TMyClass;
begin
O := TMyClass.Create;
case O.Enum of
one: WriteLn('1');
two: WriteLn('2');
else
WriteLn('something wrong :/');
end;
end.
Ondrej
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20170714/3955003b/attachment.html>
More information about the fpc-devel
mailing list