From: Matt Harren <matth@cs...> - 2005-08-04 20:39:05
> -----Original Message-----
> From: cil-users-admin@...
> [mailto:cil-users-admin@...] On Behalf Of Roy
> Sent: Thursday, August 04, 2005 1:10 PM
> To: cil-users@...
> Subject: [CIL users] Comparing Lvals
> This approach works fine for simple lvals. When I begin to
> deal with structures, such as 'foobar.bar = foobar.bar; //
> True', I run out of memory:
> Fatal error: exception Out_of_memory
The problem with structures is that compinfo and fieldinfo are mutually
recursive, and OCaml's (=) operator doesn't terminate on cyclic data
structures. Try replacing "lv1 = lv2" with "Util.equals lv1 lv2". You
also need to be careful with (<>).
Util.equals is defined as
let equals x1 x2 : bool =
(compare x1 x2) = 0
OCaml's Pervasives.compare has the same underlying implementation as (=),
except that it checks for pointer equality before recursing into
subobjects, which is enough to guarantee termination for fieldinfo and
other CIL datastructures.