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 395
    • Issues 395
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 11
    • Merge requests 11
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • sac-group
  • sac2csac2c
  • Issues
  • #2392
Closed
Open
Created Mar 07, 2024 by Artem Shinkarov@temaOwner

Bug in class implementation

Here is a definition of the class which is a counter, where the update effect is merged into the value accessor:

class cnt;
classtype int;
export all;

cnt new (int x) {
  return to_cnt (x);
}

int value (cnt &x) {
  v = from_cnt (x);
  x = to_cnt (_add_SxS_ (v, 1));
  return v;
}

Here is the file that uses this class:

use cnt:all;
int main () {
  a = new (1);
  return value (a);
}

When I run this, I get the value 2 back, but the correct result is 1.

The version of sac2c I used is: sac2c 1.3.3-MijasCosta-1161-gb543c

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking