Segmentation fault caused by unconstrained count disjunction
ChillMagic opened this issue · 1 comments
ChillMagic commented
.decl a(x: number, y: number, z: number)
a(1, 2, 0).
a(3, 4, 1).
.decl b(item: number)
b(1).
b(2).
b(3).
b(4).
.decl c(x: number, y: number)
c(x, y) :-
// a(_, y, index), // If the expression is not included, will it result in a segmentation fault
1 = count : { a(_, y, index) },
x = index,
index = range(0, 10),
b(y).
.output c(IO=stdout)
quentin commented
The generated RAM program for c
has an issue, the count
is evaluated before the range
, thus WHERE (t1.2 = t2.0)
uses t2.0
before it is bound by RANGE ... INTO t2
:
QUERY
IF (NOT ISEMPTY(b))
FOR t0 IN b
t1.0 = count UNDEF SEARCH t1 IN a ON INDEX t1.1 = t0.0 WHERE (t1.2 = t2.0)
IF (NUMBER(1) = t1.0)
RANGE(NUMBER(0),NUMBER(10)) INTO t2
IF (t1.2 = t2.0)
INSERT (t1.2, t0.0) INTO c