View Issue Details

IDProjectCategoryView StatusLast Update
0037788FPCCompilerpublic2020-09-22 12:36
ReporterWolfgang Helbig Assigned ToJonas Maebe  
PrioritynormalSeverityminorReproducibilityhave not tried
Status resolvedResolutionduplicate 
PlatformiMacOSMac OS X 
Product Version3.2.0 
Summary0037788: Overflow checking does not work
DescriptionI expected the program ov to print the message "overflow at xxx", but it ends quietly!

program ov (output);
var i: integer;
while i > 0 do i := i+i;
Steps To ReproduceCompile and run the above program and notice that no overflow message is printed.
TagsNo tags attached.
Fixed in Revision
Attached Files


duplicate of 0025201 closedJonas Maebe instead overflowcheck is used rangecheck 



2020-09-21 16:18

reporter   ~0125725

Last edited: 2020-09-21 16:19

View 2 revisions

Overflow exception depends on native integer size (32 bit, 64 bit, ...).
For assignment range error you need {$R+}

Wolfgang Helbig

2020-09-21 17:32

reporter   ~0125730

Well, the program should raise an overflow exception, because at some time not so far time i+i will overflow the integer size. For 64 bit integer after 63 iterations.
A range check would not work here, since the result of the doubling i will always be in the range of integers.


2020-09-21 17:46

reporter   ~0125731

Your declared type is integer (32 bit). The sum cannot overflow int64 if your input is 32bit.

Wolfgang Helbig

2020-09-22 09:26

reporter   ~0125746

Ah, now I understand! Thanks a lot, nanobit!

Wolfgang Helbig

2020-09-22 10:24

reporter   ~0125749

I think according to nanobit this program should raise an overflow check. But it doesn't. Now, I don't understand again! Here is a typescript.
$ cat overfl.p
program ov (output);
var i: longint;
while i > 0 do i := i+i;

$ fpc overfl.p
$ overfl

Range check works though! I yet have to see the run time error 215.


2020-09-22 10:36

reporter   ~0125750

"Integer" is longint, you have exactly the same program again.

Try this with var i: int64. This should give EIntOverflow
( either from cpu64 or from emulation (on cpu32))

Wolfgang Helbig

2020-09-22 12:36

reporter   ~0125754

surprise, surprise!: with int64 I got error 215! Fine. Thanks again!

Issue History

Date Modified Username Field Change
2020-09-21 16:07 Wolfgang Helbig New Issue
2020-09-21 16:18 nanobit Note Added: 0125725
2020-09-21 16:19 nanobit Note Edited: 0125725 View Revisions
2020-09-21 17:32 Wolfgang Helbig Note Added: 0125730
2020-09-21 17:46 nanobit Note Added: 0125731
2020-09-21 19:24 Jonas Maebe Assigned To => Jonas Maebe
2020-09-21 19:24 Jonas Maebe Status new => resolved
2020-09-21 19:24 Jonas Maebe Resolution open => duplicate
2020-09-21 19:24 Jonas Maebe FPCTarget => -
2020-09-21 19:24 Jonas Maebe Relationship added duplicate of 0025201
2020-09-22 09:26 Wolfgang Helbig Note Added: 0125746
2020-09-22 10:24 Wolfgang Helbig Note Added: 0125749
2020-09-22 10:36 nanobit Note Added: 0125750
2020-09-22 12:36 Wolfgang Helbig Note Added: 0125754