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
  • #2470
Closed
Open
Created Apr 28, 2025 by Thomas Koopman@thomasDeveloper

Array of constant unsigned long loses its `ul` suffix in the generated C-code

The following SaC program

noinline
ulong jump(ulong x)
{
  table = [1733541517147835066ul, 15395012609548302636ul,
           12202545078643706282ul, 4155657270789760540ul];
  for (i = 0; _lt_SxS_(i, 4); i = _add_SxS_(i, 1)) {
    x = _mul_SxS_(x, _sel_VxA_([i], table));
  }

  return x;
}

int main()
{
  x = 2349023ul;
  return _toi_S_(jump(x));
}

generates

      { SACp_emal_2151__dlirmov_2124_table[0] = 1733541517147835066; }
      { SACp_emal_2151__dlirmov_2124_table[1] = 15395012609548302636; }
      { SACp_emal_2151__dlirmov_2124_table[2] = 12202545078643706282; }
      { SACp_emal_2151__dlirmov_2124_table[3] = 4155657270789760540; }

As the ul suffix misses from the constants, the compiler sees them as int, and they will overflow

Compiler commit 5d970304cb7c3f44c98244fe53e7ca99d2bc66e3

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