|
|
Bugzilla Link |
415 |
Created on |
Apr 16, 2008 09:10 |
Resolution |
FIXED |
Resolved on |
Feb 24, 2009 15:39 |
Version |
1.00beta |
OS |
Linux |
Architecture |
PC |
Attachments |
exprs_minbug.sac |
Extended Description
The following program triggers a seemingly incorrect error message during compilation. The problem does not appear if the boolean array is created and used as an integer array instead.
------------------- Program ------------------------
use Array: all;
use StdIO: all;
#define HEAP_SIZE 50
#define MAX_CHILDREN 2
#define NODE_EMPTY 0
#define NODE_CONST 1
#define NODE_PLUS 2
/*
A folded version of sel.
ivs: An array of index vectors
vals: An array of values
result: Elements of vals given by the elements of ivs.
*/
int[*] fold_sel(int[+] ivs, int[*] vals){
ivshape = drop([1],shape(ivs));
resshape = drop([dim(ivshape)], shape(vals));
def = genarray(resshape, zero(vals));
res = with{ ((0*ivshape) <= iv < ivshape) :
vals[iv];
} : genarray(resshape, def);
return (res);
}
int[*] children (int parent, int[*] children, int[*] numchildren){
return (take([numchildren[parent]], children[parent]));
}
bool childrenConst(int parent, int[*] heap, int[*] children, int[*] numchildren){
childtypes = fold_sel(reshape([numchildren[parent], 1], children(parent, children, numchildren)), heap);
return (all(childtypes == NODE_CONST));
}
int, bool, int[*], int,int , bool
rewrite( int node, int[*] heap, bool[*] active, int[*]children, int[*] numchildren, int[*] value)
{
h = heap[node];
a = active[node];
c = children[node];
n = numchildren[node];
v = value[node];
done = true;
chps = children(node, children, numchildren);
if( active[node] ) {
if( heap[node] == 2) {
if( childrenConst(node, heap, c, numchildren)) {
/* del = c;*/
h = 1;
v = sum(fold_sel(reshape([1, n], chps), value));
done = false;
}
}
}
return( h,a,c,n,v, done);
}
int[*], bool[*], int[*], int[*] , int[*] , bool
rewrite( int[*] heap, bool[*] active, int[*] children, int[*] numchildren, int[*] value)
{
heap2, active2, children2, numchildren2, value2, done =
with {
( [0] <= [i] < shape(heap)) {
h,a,c,n,v,done = rewrite( i, heap, active, children, numchildren, value);
} : (h,a,c,n,v,done );
} : ( modarray( heap),
modarray( active),
modarray( children),
modarray( numchildren),
modarray( value),
fold( &, true));
return( heap2, active2, children2, numchildren2, value2, done);
}
void printHeap( int[*] heap, bool[*] active, int[*]children, int[*] numchildren, int[*] value)
{
printf( "Heap-State------------------------------------------------------------\n");
print( heap);
print( active);
print( children);
print( numchildren);
print( value);
}
int main()
{
heap = [ 2,1,2,2,1,1,2,1,1,0];
active = [true, true, true, true, true, true, true, true, true, false];
/*active = genarray([10], 0);*/
children = reshape([10, MAX_CHILDREN], [ 1, 0,3, 4, 0,0,7,0,0,0, 2, 0, 6, 5, 0,0,8,0,0,0]);
numchildren = [2, 0, 2, 2, 1, 1, 2, 1, 1, 0];
value = [ 0,3, 0,0,1,2,0,4,5,0];
printHeap( heap, active, children, numchildren, value);
done = false;
swoops = 0;
while(!done) {
heap, active, children, numchildren, value, done = rewrite( heap, active, children, numchildren, value);
swoops++;
}
printf(" after %d reduction swoops we have:\n", swoops);
printHeap( heap, active, children, numchildren, value);
return(0);
}
------------------- Program End ------------------------
------------------- Error Message ----------------------
hack03@obelix:~/lang$ sac2c exprs.sac -check tc
WARNING: Option -check c implies option -ecc.
WARNING: Insertion of explicit conformity checks has been enabled.
ERROR: line 105 file: exprs.sac
ERROR: loop variable "active" is being used inconsistently; conflicting
ERROR: types are bool[10]{175...} and #21408: in [ --, bool[10]{147...}] le
ERROR: <> ge <>
*** Compilation failed ***
*** Exit code 71 (Running SAC optimizations)
*** 1 Error(s), 1 Warning(s)
hack03@obelix:~/lang$
------------------- Error Message End----------------------