Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • sac2c sac2c
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 402
    • Issues 402
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 13
    • Merge requests 13
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • sac-group
  • sac2csac2c
  • Issues
  • #2313
Closed
Open
Created Mar 24, 2022 by Robert Bernecky@rbeDeveloper

semantics of abs() does not check against overflows

I have been chasing problems with array formatting in apex. I narrowed it down to this just now:

sac2c_d -V
sac2c 1.3.3-MijasCosta-799-gb7a97
build-type: DEBUG
built-by: "sac" at 2022-03-23T09:54:38
// after -bopt:cyc:tup:1, the result of abs(v) is AKV.     This is awesome.
// after -bopt:cyc:tup:1, the value of abs(v) is negative. This is awful.

use Array:all;

int main()
{
  v = -2147483648; 

  StdIO::print(v);
  StdIO::print( abs(v));

return(0);
}

NB. The value of v is critical here.

Edited Mar 29, 2022 by Sven-Bodo Scholz
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking