/* * This program produces a memory leak in EMM (because of EACC) * * parameters: * correct: -trace mr -nowlur -o leak leak.sac -v0 * leaky: -emm -trace mr -nowlur -o leak leak.sac -v0 * * The bug results from accu() being eliminated during sacopt. */ /* * Problem: function does not use its first argument and is inlined. * * correct behaviour would be something like: * res = with (. <= iv <= .) genarray( shape(a), a[iv]+b[iv]); */ inline int[.] second( int[.] a, int[.] b) { res = b; return(res); } /* * This function's sole purpose is to point out the memory leak */ int[.] f( int[.] iv, int[.] A) { return( A); } int main() { A = with (. <= iv <= .) genarray( [1024], 1); n = with (. <= iv <= .) genarray( [1024], 0); F = with ([0] <= iv < [10]) fold ( second, n, f(iv,A)); return( F[[0]]); }