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
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel