[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Segmentation fault with constraints involving many terms.
From: |
Thierry Martinez |
Subject: |
Segmentation fault with constraints involving many terms. |
Date: |
Wed, 6 Mar 2013 16:25:20 +0100 |
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.
- Segmentation fault with constraints involving many terms.,
Thierry Martinez <=