Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2019-06

Error? No range checks in mode delphi?

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Anthony Walter

Is the following a bug in the compiler or a feature? Is would seem using {$mode delphi} allows code which clearly violates range bound to compile without error.

program Project1;
{$mode delphi}
type
  TSuit = (suHeart, suDiamond, suClub, suSpade);
  TRedSuit = suHeart..suDiamond;
var
  Suit: TRedSuit;
begin
  // This should generate an error, but {$mode delphi} allows it
  Suit := suClub;
end.

Reply by email

Marcos Douglas B. Santos
to Anthony Walter
PM Anthony Walter wrote 17 lines
Is the following a bug in the compiler or a feature? Is would seem using {$mode delphi} allows code which clearly violates range bound to compile without error. program Project1; {$mode delphi} type TSuit = (suHeart, suDiamond, suClub, suSpade); TRedSuit = suHeart..suDiamond; var Suit: TRedSuit; begin // This should generate an error, but {$mode delphi} allows it Suit := suClub; end.

Debugging option -> check Range (-Cr)

regards,
Marcos Douglas

Reply by email

Sven Barth
to Anthony Walter

Anthony Walter schrieb am Di., 4. Juni 2019, 03:27:

That fixes it, but then the question is why does {$mode delphi} differ from {$mode objfpc}?

Mode ObjFPC is stricter in some cases. While mode Delphi cares for Delphi compatibility.

Regards,
Sven

Reply by email