Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
  • Sign in / Register
  • FPC Source FPC Source
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 1,277
    • Issues 1,277
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 57
    • Merge requests 57
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar

Scheduled maintenance on the database layer will take place on 2022-07-02. We expect GitLab.com to be unavailable for up to 2 hours starting from 06:00 UTC. Kindly follow our status page for updates and read more in our blog post.

  • FPC
  • FPC
  • FPC SourceFPC Source
  • Issues
  • #15453
Closed
Open
Created Jan 01, 2010 by FPC Admin account@fpc_adminOwner

Negative dividend: makes DivMod raise EDivByZero, makes mod return wrong value

Original Reporter info from Mantis: Michalis @michaliskambi
  • Reporter name: Michalis Kamburelis

Description:

(Observed with released 2.4.0, tagging with "2.4.1" in mantis as there's no "2.4.0" choice yet.)

Submitting this as one bug, although I'm not sure --- maybe these are two not related bugs (one for Math.DivMod, one for the "mod" operator). Neither of these problems were observed with 2.2.4.

The program calculates "-9 div/mod 5" in two ways: 1. call "div" and "mod" operators separately, 2. call DivMod.

Running with 2.2.4 we get correct results from both approaches:

$ fpc -gl divmod.pas
$ ./divmod
-1 -4
-1 -4

Running with 2.4.0 we get:

$ fpc -gl divmod.pas
$ ./divmod
-1 2
An unhandled exception occurred at $080637FD :

EDivByZero : Division by zero<br/>
  $080637FD
  $0804812E  main,  line 10 of divmod.pas

So the "-9 mod 5" returns wrong value (2) and DivMod(-9, ...) raises EDivByZero exception.

Mantis conversion info:

  • Mantis ID: 15453
  • OS: Debian GNU/Linux
  • OS Build: (testing)
  • Platform: i386
  • Version: 2.4.0
  • Fixed in version: 2.4.2
  • Fixed in revision: 15201 (#78e19bdd)
  • Target version: 2.4.2
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking