View Issue Details

IDProjectCategoryView StatusLast Update
0017685FPCCompilerpublic2011-10-30 16:18
ReporterAdriaan van Os Assigned ToFlorian  
PrioritynormalSeverityminorReproducibilitysometimes
Status resolvedResolutionfixed 
PlatformDarwin i386OSMac OS X 
Product Version2.5.1 
Fixed in Version3.0.0 
Summary0017685: Conformance of the mod operator
Description{$mode iso}
program modulo( Output);
var
  i, j, m : integer;
begin
  i := -10;
  j := 100;
  m := i mod j;
  Writeln( ' m = ', i: 3, ' mod ', j: 3, ' = ', m: 3);
  Writeln( '-10 mod 100 = ', -10 mod 100 :3);
end.

In ISO mode this should print 90 twice instead of -10. See section 6.7.2.2 Arithmetic operators of the ISO-7185:1990 standard:

: A term of the form i mod j shall be an error if j is zero or negative; otherwise, the value of i mod
j shall be that value of (i-(k*j)) for integral k such that 0 <= i mod j < j. :

TagsNo tags attached.
Fixed in Revision19558
FPCOldBugId
FPCTarget
Attached Files

Activities

Florian

2010-10-24 19:44

administrator   ~0042063

Funny, and I though a validation suite should find such simple failures. I'll look into fixing FPC.

Marco van de Voort

2010-10-24 22:33

manager   ~0042072

(I don't know about ISO Pascal, but ISO Modula2 afaik uses the REM (remainder) operator for the Borland-like definition, supporting both variants in the same dialect)

Adriaan van Os

2010-10-25 11:20

developer   ~0042091

I were wrong about the "-10 mod 100" case though, see <http://www2.gnu-pascal.de/crystal/gpc/en/mail15008.html>

Adriaan van Os

2010-10-25 11:23

developer   ~0042092

And note that the iso mode differs here from other modes <http://wiki.freepascal.org/Mod>.

Florian

2011-10-30 16:18

administrator   ~0053642

Remark: FPC throws an div by zero runtime error if the divisor is <=0.

Issue History

Date Modified Username Field Change
2010-10-22 14:14 Adriaan van Os New Issue
2010-10-24 19:44 Florian Note Added: 0042063
2010-10-24 22:33 Marco van de Voort Note Added: 0042072
2010-10-25 11:20 Adriaan van Os Note Added: 0042091
2010-10-25 11:23 Adriaan van Os Note Added: 0042092
2011-10-30 16:18 Florian Fixed in Revision => 19558
2011-10-30 16:18 Florian Status new => resolved
2011-10-30 16:18 Florian Fixed in Version => 2.7.1
2011-10-30 16:18 Florian Resolution open => fixed
2011-10-30 16:18 Florian Assigned To => Florian
2011-10-30 16:18 Florian Note Added: 0053642