[m-rev.] fix C conformance error for zero-arity RTTI data

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Aug 14 13:37:51 AEST 2003


Estimated hours taken: 1
Branches: main

Fix a bug where we were generating invalid C code which resulted
in compilation errors when compiling with lcc.  This bug showed up for
tests/dppd/run.m.

compiler/rtti_out.m:
	Ensure that we do not output "{}" as an initializer,
	since ISO C does not support empty initializers.
	Instead, output an initializer with a dummy element (0),
	with a comment explaining why.

Workspace: /home/ceres/fjh/mercury
Index: compiler/rtti_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/rtti_out.m,v
retrieving revision 1.37
diff -u -d -r1.37 rtti_out.m
--- compiler/rtti_out.m	14 May 2003 00:10:03 -0000	1.37
+++ compiler/rtti_out.m	14 Aug 2003 03:32:18 -0000
@@ -1187,7 +1187,10 @@
 :- pred output_cast_addr_of_rtti_datas(string::in, list(rtti_data)::in,
 	io__state::di, io__state::uo) is det.
 
-output_cast_addr_of_rtti_datas(_, [], !IO).
+output_cast_addr_of_rtti_datas(_, [], !IO) :-
+	io__write_string(
+	  "\t/* Dummy entry, since ISO C forbids zero-sized arrays */\n", !IO),
+	io__write_string("\t0\n", !IO).
 output_cast_addr_of_rtti_datas(Cast, [RttiData | RttiDatas], !IO) :-
 	io__write_string("\t", !IO),
 	io__write_list([RttiData | RttiDatas], ",\n\t",

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list