Hi all,

I've been having a few problems with incomplete types in CIL.

Apparently, Cil.isCompleteType considers a structure with no fields as
being a complete type. I don't know if this is on purpose, or if this
is a bug. It seems to be valid C, but I can't see any use of having a
structure defined with no fields. The problem is that incomplete
structures also appear in CIL as structures with no fields, so in my
code I cannot make the difference and I end up generating code that
doesn't compile (such as calling sizeof on an incomplete structure).

I patched the isCompleteType method in my CIL source tree in the following way:

--- src/cil.ml.orig   2009-04-06 15:16:20.000000000 +0200
+++ src/cil.ml  2009-04-06 15:18:51.000000000 +0200
@@ -6074,7 +6074,10 @@
   | TArray(t, None, _) -> false
   | TArray(t, Some z, _) when isZero z -> false
   | TComp (comp, _) -> (* Struct or union *)
-      List.for_all (fun fi -> isCompleteType fi.ftype) comp.cfields
+      if (List.length comp.cfields) == 0 then
+        false
+      else
+        List.for_all (fun fi -> isCompleteType fi.ftype) comp.cfields
   | _ -> true

This seems to be doing the trick for me, but it's ruling out the
possibility of having a complete structure with no fields, so if this
is indeed being used by some people, it might cause them problems. Any
thoughts ?

Thanks,

Olivier

------------------------------------------------------------------------------
_______________________________________________
CIL-users mailing list
CIL-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cil-users

Reply via email to