2
votes
var
    a: Integer;  
begin 
    a:= 300;  
    if a in [100..500] then  
        WriteLn ('YES')    
    else  
        WriteLn ('NO')  
end.
1
It seems that freepascal only allows values <256 for sets, as can be seen here. No warning seems to be generated by the compiler. - Karsten Koop
Oh, yes, maybe. Thank you! - IGOR_IGOR
FPC gives this warning: xxx.pas(1,46) Warning: range check error while evaluating constants (500 must be between 0 and 255) Do you ignore warnings? - tonypdmtr

1 Answers

7
votes

Pascal supports only numbers between 0 and 255 in sets, according to the FreePascal documentation. The significant portion is here:

Each of the elements of SetType must be of type TargetType. TargetType can be any ordinal type with a range between 0 and 255. A set can contain at most 255 elements.

Turning on range checking {$R+} will cause the compiler to warn you of these sorts of errors.