[PPL-devel] Big problems with not-so-big numbers

Roberto Bagnara bagnara at cs.unipr.it
Sun Jan 15 12:03:03 CET 2006


Below the signature is everything needed to reproduce the problem
under GNU/Linux.  I have checked the YAP sources, but did not succeed
in finding what may cause this behavior.
All the best,

    Roberto

-- 
Prof. Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.it/~bagnara/
mailto:bagnara at cs.unipr.it

$ cat bug.c
#include <Yap/YapInterface.h>
#include <limits.h>

YAP_Bool
long_min(YAP_Term t) {
   return YAP_Unify(t, YAP_MkIntTerm(LONG_MIN));
}

YAP_Bool
yap_stub_long_min() {
   YAP_Term arg1 = YAP_A(1);
   return long_min(arg1);
}

void
init() {
   YAP_UserCPredicate("long_min", (int(*)())(yap_stub_long_min), 1);
}
$ gcc -c -shared -fPIC bug.c
$ ld -shared -o bug.so bug.o
$ yap
% Restoring file /usr/local/lib/Yap/startup
YAP version Yap-5.1.0
    ?- load_foreign_files(['bug'],[],init).
yes
    ?- long_min(M).
M = -2147483648 ?
yes
    ?- long_min(M), M == -2147483648.
no
    ?- long_min(M), M = -2147483648.
no
    ?- long_min(M), M is 0 - 2147483648.
no
    ?- long_min(M), M1 is abs(M).
M = M1 = -2147483648 ?
yes
    ?- $



More information about the PPL-devel mailing list