Error? No range checks in mode delphi?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Error? No range checks in mode delphi?

Anthony Walter-3
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. 

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Error? No range checks in mode delphi?

Marcos Douglas B. Santos
On Mon, Jun 3, 2019 at 4:46 PM Anthony Walter <[hidden email]> wrote:

>
> 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Error? No range checks in mode delphi?

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

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Error? No range checks in mode delphi?

Free Pascal - General mailing list
Anthony Walter <[hidden email]> 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 

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal