[fpc-pascal] For .. in .. loops with sets and valued enums

Torsten Bonde Christiansen tc at epidata.info
Fri Jun 19 09:46:10 CEST 2015


Consider the following program:

program Project1;

type
   TMyEnum = (
     a = 1,
     b = 3,
     c = 5
   );
   TMySet = set of TMyEnum;
var
   Item: TMyEnum;

begin
   for Item in TMySet do
     Writeln('Value = ', Integer(Item));
end.


I would expect the output of the program to contain the values 1, 3 and 
5 only. But the actual output is:
Value = 1
Value = 2
Value = 3
Value = 4
Value = 5

Is this a bug or a know limitation of the "for ... In ... do" loop?

I am using fpc 2.6.4

Regards,
Torsten.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20150619/f5e4bf63/attachment.html>


More information about the fpc-pascal mailing list