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