Bug, or at least something wrong

Felipe Ignacio Canas Sabat <[email protected]>
Newsgroups gmane.comp.gnu.prolog.bugs
Message-ID <[email protected]>
Hello,

These are the commands I am using:

%%%%%%%%%%%%
even(X) :-
  A is X mod 2,
  A == 0.

odd(X) :-
  A is X mod 2,
  A == 1.

step(X,Y) :-
  X > 1,
  even(X),
  Y is X/2.

step(X,Y) :-
  X > 1,
  odd(X),
  Y is 3*X + 1.
%%%%%%%%%%%%

And this is what I'm running:

  | ?- step(32,X), step(X,Y), step(Y,Z).

And this is the error I get:

  uncaught exception: error(type_error(integer,16.0),(is)/2)

I don't get this error when I run it on SWI-prolog, and I really don't
see what the error is. This is the trace:

      1    1  Call: step(32,_16) ?
      2    2  Call: 32>1 ?
      2    2  Exit: 32>1 ?
      3    2  Call: even(32) ?
      4    3  Call: _166 is 32 mod 2 ?
      4    3  Exit: 0 is 32 mod 2 ?
      5    3  Call: 0==0 ?
      5    3  Exit: 0==0 ?
      3    2  Exit: even(32) ?
      6    2  Call: _16 is 32/2 ?
      6    2  Exit: 16.0 is 32/2 ?
      1    1  Exit: step(32,16.0) ?
      7    1  Call: step(16.0,_20) ?
      8    2  Call: 16.0>1 ?
      8    2  Exit: 16.0>1 ?
      9    2  Call: even(16.0) ?
*    10    3  Call: _320 is 16.0 mod 2 ?
*    10    3  Exception: _332 is 16.0 mod 2 ?
      9    2  Exception: even(16.0) ?
      7    1  Exception: step(16.0,_20) ?

I put the asterisks next to the lines where I see something strange
happening. Namely, it goes from assigning something to _320 to then
report an exception concerning _332.

What's more, after running the same instruction once more, I get a
Segmentation Fault. I couldn't figure out how to build a not stripped
binary, so no backtrace, sorry.

Some required info:

Machine:
Linux <hostname> 2.6.18-5-686 #1 SMP <date> i686 GNU/Linux

Distro:
Debian 4.0r1 (Etch)

GNU Prolog version:
1.3.0

Hope it helps.

Bye,
-Felipe
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.