Hi!

The following program leads to a segmentation fault, possibly after
having printed ”here” (and more precisely, when telling the constraint
Sum #> 0), with all versions of GNU Prolog at least since 1.4.1. The
length of the sum leading to the error may vary depending on the
architecture.

:- initialization(test).

test :-
   test_sum_n(162),
   print(here),
   nl,
   test_sum_n(163).

test_sum_n(N) :-
   length(VarList, N),
   build_sum(VarList, Sum),
   Sum #> 0.

build_sum([], 0).
build_sum([A], A) :- !.
build_sum([H1, H2 | T], S + H1):-
   build_sum([H2 | T], S).

Changing build_sum by introducing intermediate FD variables solves the problem.

build_sum([], 0).
build_sum([A], A) :- !.
build_sum([H1, H2 | T], Sum):-
   Sum #= S + H1,
   build_sum([H2 | T], S).

--
Thierry.

_______________________________________________
Bug-prolog mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-prolog

Reply via email to