Recent

Author Topic: Why is this error not identified even with Debug mode and Range checks On  (Read 662 times)

Ten_Mile_Hike

  • Full Member
  • ***
  • Posts: 135
Code: Text  [Select][+][-]
  1. Environment[Win 11, Laz 4.0RC2, FPC 3.2.2, {$mode objfpc}, Debug mode]
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. type
  3.   q = 1..10;
  4. var
  5.   x: integer;
  6.   Mark: set of q;
  7. begin
  8.   Mark := [5, 11];{<-Why doesn't 11 cause a range check error?}
  9.   for x in Mark do Memo1.Lines.add(IntToStr(x) + ' IN Mark');
  10. end;
When any government, or any church for that matter, undertakes to say to its subjects, This you may not read, this you
must not see, this you are forbidden to know, the end result is tyranny and oppression no matter how holy the motives.

Robert A. Heinlein

Thaddy

  • Hero Member
  • *****
  • Posts: 18764
  • To Europe: simply sell USA bonds: dollar collapses
Re: Why is this error not identified even with Debug mode and Range checks On
« Reply #1 on: February 04, 2025, 07:03:03 am »
Yes, strange. It only fails with assignment, though:
Code: Pascal  [Select][+][-]
  1. // mark := [5,11] // should fail, but does not.
  2.   mark :=[]
  3.   include(mark,5);// OK
  4.   include(mark,11)// fails, rangecheck error
OTOH the for in do doesn't see the 11 as part of the set so that behaves correct.
I also tested making the set a type too, but the same behavior: it does not range check the inititial set assignment.
This is a bug indeed, also in 3.3.1.
I will report it with a simplified example.
« Last Edit: February 04, 2025, 02:04:38 pm by Thaddy »
If Europe sells their USA bonds the USD will collapse. Europe can affort that given average state debts. The USA can't affort that. Just an advice...

Thaddy

  • Hero Member
  • *****
  • Posts: 18764
  • To Europe: simply sell USA bonds: dollar collapses
Re: Why is this error not identified even with Debug mode and Range checks On
« Reply #2 on: February 04, 2025, 07:17:21 am »
Reported as #41132 with this simplified full program:
Code: Pascal  [Select][+][-]
  1. {$mode objfpc}{$H+}{$R+}
  2. type
  3.   TmyRange = 1..10;
  4. var
  5.   x: integer;
  6.   Mark: set of TmyRange;
  7. begin
  8.   Mark := [5,11];{<-Why doesn't 11 cause a range check error?}
  9.   for x in Mark do write(x,' IN Mark');
  10. end.
If Europe sells their USA bonds the USD will collapse. Europe can affort that given average state debts. The USA can't affort that. Just an advice...

 

TinyPortal © 2005-2018