View Issue Details

IDProjectCategoryView StatusLast Update
0035671FPCCompilerpublic2021-04-11 12:06
Reporterrd0x Assigned ToJonas Maebe  
Status closedResolutionfixed 
Product Version3.2.0 
Fixed in Version3.2.0 
Summary0035671: Enable range check for Delphi-mode
DescriptionFrom Anthony Walter on mailing list:

In Delphi Rio it triggers:
[dcc32 Error] Project1.dpr(16): E1012 Constant expression violates subrange bounds

So I think its a good idea to enable range checking by default for Delphi-mode for better compiler compatibility
Steps To Reproduceprogram Project1;

{$mode delphi}

  TSuit = (suHeart, suDiamond, suClub, suSpade);
  TRedSuit = suHeart..suDiamond;

  Suit: TRedSuit;
  // This should generate an error, but {$mode delphi} allows it
  Suit := suClub;
TagsNo tags attached.
Fixed in Revision42272,43367 - 42275,43367
Attached Files


related to 0035753 resolvedJonas Maebe Delphi allows dereferencing a pointer to a [0..0] static array and accessing it with indices > 0, however 0035671 breaks this. 


Thaddy de Koning

2019-06-07 17:59

reporter   ~0116613


testme.pas(12,11) Warning: (4110) Range check error while evaluating constants (2 must be between 0 and 1)

So what exactly do you want?
You can always compile with -Sew (treat warnings as errors)

Marco van de Voort

2019-06-07 19:03

manager   ~0116616

(note that compiletime and runtime range checking are different things. Enabling normal runtime checking would only give you an error at runtime)


2019-06-07 21:07

reporter   ~0116617

When compiling this example in Delphi it gives you a compile time error and stops. (as written above)
FPC compiles it and you can run it, in my eyes this is not Delphi compatible as it should act the same in {$mode delphi}. Thats what Delphi mode is for or?

Thaddy de Koning

2019-06-08 07:46

reporter   ~0116619

Last edited: 2019-06-08 07:48

View 2 revisions

FPC throws a warning. With -Sew it throws an error.

 fpc -Sew warnings.pas
Free Pascal Compiler version 3.3.1-r42152 [2019/06/01] for arm
Copyright (c) 1993-2018 by Florian Klaempfl and others
Target OS: Linux for ARMHF
Compiling warnings.pas
warnings.pas(12,11) Warning: Range check error while evaluating constants (2 must be between 0 and 1)
warnings.pas(14) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: /usr/local/bin/ppcarm returned an error exitcode

I only changed the name of your program. Looks to me enough.


2019-06-08 08:46

reporter   ~0116620

Delphi throws an error by default, so FPC should enable -Sew in {$mode Delphi} as default too

Marco van de Voort

2019-06-08 11:44

manager   ~0116625

Only recent delphis do, and we are not errormessage compatible to delphi.

And the -Sew is a complete nono, since that turns every warning into an error


2019-06-08 13:18

reporter   ~0116627

Runtime range checks ($R) must be default-disabled in Delphi mode, as Delphi (and TP) are formally defined in {$R-}.

Compile time rangechecks are different, and in this examle is (and always has been) an error:
[DCC Fehler] Project1.dpr(13): E1012 Konstantenausdruck verletzt untere Grenzen

Issue History

Date Modified Username Field Change
2019-06-03 21:10 rd0x New Issue
2019-06-07 17:59 Thaddy de Koning Note Added: 0116613
2019-06-07 19:03 Marco van de Voort Note Added: 0116616
2019-06-07 21:07 rd0x Note Added: 0116617
2019-06-08 07:46 Thaddy de Koning Note Added: 0116619
2019-06-08 07:48 Thaddy de Koning Note Edited: 0116619 View Revisions
2019-06-08 08:46 rd0x Note Added: 0116620
2019-06-08 11:44 Marco van de Voort Note Added: 0116625
2019-06-08 13:18 Martok Note Added: 0116627
2019-06-22 17:30 Jonas Maebe Assigned To => Jonas Maebe
2019-06-22 17:30 Jonas Maebe Status new => resolved
2019-06-22 17:30 Jonas Maebe Resolution open => fixed
2019-06-22 17:30 Jonas Maebe Fixed in Version => 3.3.1
2019-06-22 17:30 Jonas Maebe Fixed in Revision => 42272
2019-06-22 17:30 Jonas Maebe FPCTarget => -
2019-06-22 19:52 Jonas Maebe Relationship added related to 0035753
2019-08-02 14:50 rd0x Status resolved => closed
2021-04-11 12:05 Jonas Maebe Fixed in Version 3.3.1 => 3.2.0
2021-04-11 12:05 Jonas Maebe Fixed in Revision 42272 => 42272,43367
2021-04-11 12:06 Jonas Maebe Fixed in Revision 42272,43367 => 42272,43367 - 42275,43367