[PPL-devel] x still a variable after a successful call to c2p_list(x) (2nd attempt)

Roberto Bagnara bagnara at cs.unipr.it
Mon Aug 5 21:52:19 CEST 2002


Dear all,

following the advice of Kostis, here is something anyone
can easily run to try reproducing what seems a rather
serious bug in XSB.  The files foo.c and foo.H follow:

------------------------------ foo.c ------------------------------
#include <cinterf.h>
#include <stdio.h>

xsbBool foo() {
   prolog_term x = p2p_new();
   if (is_var(x) == TRUE)
     printf("`x' is a variable: fine!\n");
   if (c2p_list(x) == TRUE)
     printf("`c2p_list(x)' succeeded: fine!!\n");
   // Hey, how can `x' still be a variable?
   if (is_var(x) == TRUE)
     printf("`x' is still a variable!!!\n");
   return TRUE;
}
--------------------------- end of foo.c --------------------------

------------------------------ foo.H ------------------------------
:- export
	foo/0.
--------------------------- end of foo.H --------------------------

Then assume your XSB emulator directory is

   /usr/local/lib/xsb/2.5/emu

and run

echo "consult(foo, [cc('gcc'), cc_opts('-I/usr/local/lib/xsb/2.5/emu')]), foo." | xsb

What I see is

[xsb_configuration loaded]
[sysinitrc loaded]
[packaging loaded]

XSB Version 2.5 (Okocim) of March 11, 2002
[i686-pc-linux-gnu; mode: optimal; engine: slg-wam; gc: indirection; scheduling: local]

| ?- [Compiling Foreign Module ./foo (Prolog compiler options are ignored)]
[foo compiled, cpu time used: 0.0000 seconds]
[Compiling C file ./foo.c using gcc]
In file included from /usr/local/lib/xsb/2.5/emu/export.h:28,
                  from /usr/local/lib/xsb/2.5/emu/cinterf.h:155,
                  from foo.c:1:
/usr/local/lib/xsb/2.5/config/i686-pc-linux-gnu/xsb_config.h:275:28: warning: no newline at end of file
[foo loaded]
`x' is a variable: fine!
`c2p_list(x)' succeeded: fine!!
`x' is still a variable!!!

yes
| ?-
End XSB (cputime 0.04 secs, elapsetime 0.16 secs)

The warning given by gcc constitutes a problem in xsb_config.h that is totally
unrelated, of course.
Please let me know if you need further information.
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




More information about the PPL-devel mailing list