[m-dev.] Warning compiling io.c

Tyson Richard DOWD trd at cs.mu.oz.au
Tue Feb 11 10:14:19 AEDT 1997


> Hi
> 
> The following warning:
> io.c: In function `mercury__io_module100':
> io.c:5418: warning: assignment makes integer from pointer without a cast
> when compiling io.c seems to come from std_util.m (via cross module inlining).
> I think it might be necessary to put some casts in the univ-handling code.
> Fergus, is this yours? Tyson maybe?

I'll fix it.

It's caused by this, in io__init_state:

        type_to_univ("<globals>", Globals),

this generates C code declaration of Type as:

	String Type;

which has the impressively casted initialization of

	Type = (String) (Word) (const Word *) string_const("<globals>", 9);

and, since it's a string, doesn't mesh well with this:

	field(mktag(0), Univ, UNIV_OFFSET_FOR_DATA) = Type;

The fix is, of course, this:

Index: std_util.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/library/std_util.m,v
retrieving revision 1.67
diff -u -r1.67 std_util.m
--- std_util.m	1997/02/06 23:10:36	1.67
+++ std_util.m	1997/02/10 23:05:06
@@ -680,13 +680,13 @@
 	% in the second field.
 :- pragma(c_code, type_to_univ(Type::di, Univ::uo), "
 	incr_hp(Univ, 2);
-	field(mktag(0), Univ, UNIV_OFFSET_FOR_TYPEINFO) = TypeInfo_for_T;
-	field(mktag(0), Univ, UNIV_OFFSET_FOR_DATA) = Type;
+	field(mktag(0), Univ, UNIV_OFFSET_FOR_TYPEINFO) = (Word) TypeInfo_for_T;
+	field(mktag(0), Univ, UNIV_OFFSET_FOR_DATA) = (Word) Type;
 ").
 :- pragma(c_code, type_to_univ(Type::in, Univ::out), "
 	incr_hp(Univ, 2);
-	field(mktag(0), Univ, UNIV_OFFSET_FOR_TYPEINFO) = TypeInfo_for_T;
-	field(mktag(0), Univ, UNIV_OFFSET_FOR_DATA) = Type;
+	field(mktag(0), Univ, UNIV_OFFSET_FOR_TYPEINFO) = (Word) TypeInfo_for_T;
+	field(mktag(0), Univ, UNIV_OFFSET_FOR_DATA) = (Word) Type;
 ").
 
 	% Backward mode - convert from univ to type.

-- 
       Tyson Dowd           #          Another great idea from the 
                            #            people who brought you
      trd at .cs.mu.oz.au      #               Beer Milkshakes!
http://www.cs.mu.oz.au/~trd #	         Confidence --- Red Dwarf



More information about the developers mailing list