Program( shown below) type checks okay , but produce errors when building
with patscc . However when I comment the line :
val () = !p2.data := 200
patscc build the program without any error.
I invoke patscc like this :
patscc -DATS_MEMALLOC_LIBC -o ex1 ex1.dats
Any idea whats happening.
Thanks
ex1.dats :
#include “share/atspre_define.hats”
#include “share/atspre_staload.hats”
%{
struct slist {
int data;
struct slist *next;
} ;
%}
typedef CNode = $extype_struct"struct node {
int data;
struct node * next;
}"
of {data= int , next= ptr}
implement main0 () = () where {
val () = println! (“Example 1”)
//Allocate node in memory
val (pf, pfgc | p1) =
ptr_alloc ()
val () = !p1.data := 100
val (pf1, pfgc1 | p2) =
ptr_alloc ()
(* If I comment out the line below , then build have no probs *)
val () = !p2.data := 200
//Free node from memory
val () = ptr_free{…}{…} (pfgc , pf | p1)
val () = ptr_free{…}{…} (pfgc1 , pf1 | p2)
}