help! Is this a bug? lazarus / 13-General ---------------------------------------------------------------------- Neo2010 · 2010-01-27 13:21 Hello to everyone! I wonder can anybody tell me whether this is a bug -- When "Verify method calls"(Compiler options for project --> code) is checked, such code as below will report run error: procedure TForm1.Button1Click(Sender: TObject); var   J: Integer; begin   J := -1;   if 1 in [0..J] then     ShowMessage('OK'); end;  Best regards and many thx! ---------------------------------------------------------------------- theo · 2010-01-27 13:29 I don't think it is a (FPC) bug. Like this, it doesn't even compile: Code: [Select]procedure TForm1.Button1Click(Sender: TObject); const K=-1; begin   if 1 in [0..K] then     ShowMessage('OK'); end; ---------------------------------------------------------------------- Neo2010 · 2010-01-28 01:08 Thank you theo! But in Delphi my code doesn't generate any  runtime error, so I'm really confused if this is fpc's special featrue which is designed to be different with Delphi or something else? ---------------------------------------------------------------------- Paul Ishenin · 2010-01-28 01:37 This is a new feature for FPC and some things that delphi allows can fail. I will look at this issue but better if you create a bug report so this will not be forgotten. ---------------------------------------------------------------------- Neo2010 · 2010-01-28 05:25 Many Thanks, Paul Because I don't know where to post a bug report, and I think even this really is a bug, it is a negligible "bug", so I will not create a bug report. But if you can fix in the future version of fpc, I will reall appreciate it. Best regards to every one! ---------------------------------------------------------------------- Paul Ishenin · 2010-01-28 05:52 Oups, sorry. I misread your code. I read it as for i in [0..K] then   ShowMessage('OK'); ---------------------------------------------------------------------- Paul Ishenin · 2010-01-28 05:58 By the way, I checked you code with fpc 2.5.1 and everything works ok. I see 'OK' message box and no runerror. ---------------------------------------------------------------------- Neo2010 · 2010-01-28 09:05 I have retested my code: procedure TForm1.Button1Click(Sender: TObject); var   I, J: Integer; begin   J := -1;   I := 1;   if I in [0..J] then     ShowMessage('runtime error not found'); end; and was totally confused. if "Verify method calls" option is not checked, then it will generate no runtime error, but the msg 'runtime error not found' will show, which means 1 is in [0..-1](totally wrong! because an empty set can't have any element mathematically speaking). If "Verify method calls" option is  checked, then a runtime error will be throw out. This is getting more and more interesting. Can anybody help test this code again, thanks! compile environment: fpc 2.5.1 laz 0.9.29 OS: win32  xp sp2 ---------------------------------------------------------------------- theo · 2010-01-28 10:04 Afaik, a set can not contain negative values (only byte range). That explains why it doesn't compile if "J" is a const (see my example). That explains why it does "bullshit" at runtime with no err. chechking. That explains why it throws a runtime error with err. checking on. It's not that misterious imho. Maybe things have changed in FPC 2.5.1 You can ask the FPC developers in the FPC mailing lists: http://www.freepascal.org/maillist.var ---------------------------------------------------------------------- Neo2010 · 2010-01-28 11:00 Theo, many thanks! You're right, I rechecked the ref of fpc, it does say that the base type of Set can only be ordinal type with arange between 0 and 255. So my code is wrong, fpc is right. Case closed! Enjoy fpc and Laz! Best regards!