[sac-user] understanding compiler error

Andreas Boysen abo at informatik.uni-kiel.de
Mon Nov 5 13:29:23 CET 2018


Hello,

I'm trying to write a sac program that uses subtyping to address the 
special case of an empty array. My problem is that i don't under stand 
why i get an sac2c optimization error. can someone tell me what I'm 
doing wrong?

Thanks in advance

Andreas

------

sac2c terminates with:

------


error: line 152 in file 
/home/adler/sac/Stdlib/src/structures/ArrayBasics.xsac:
error: argument #1 of "_sel_VxA_" should be legal index into argument 
#2; types found: int[1]{0}  and  int[0]
compilation failed while Running SAC optimizations.

------

the program:

------

use Array: all;
use StdIO: all;

int maxi(int[] x)
{
   printf("<error message>");
   return 0;
}

int maxi(int[+] x)
{
   tmp = x[0];
   for (i = 0; i < (shape(x))[0]; i++) {
     tmp = tmp > x[i] ? tmp : x[i];
   }
   return tmp;
}


int main()
{
   print(maxi([]));
   print(maxi([1,2,42,4]));

   return 0;
}


More information about the sac-user mailing list