[m-rev.] fix another RTTI bug with reserved addresses

Fergus Henderson fjh at cs.mu.OZ.AU
Sun Oct 27 14:18:27 AEDT 2002


Estimated hours taken: 1
Branches: main

Fix a bug introduced in Zoltan's recent RTTI changes that caused a
compiler abort when compiling types with a single constant functor,
e.g. std_util__unit, in grade `il' with `--num-reserved-addresses 1'.

compiler/rtti.m:
	In type_ctor_details_num_ptags, handle the case where a type
	has *all* of its functors represented using reserved addresses.

	Also, fix some junk that appears to have been accidentally
	pasted into a comment.

	Also, fix a misleading variable name "ResFunctors" which actually
	contained a list of all the functors in the type, not just those
	represented using reserved addresses.

Workspace: /home/ceres/fjh/ws-ceres2/mercury
Index: compiler/rtti.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/rtti.m,v
retrieving revision 1.20
diff -u -d -r1.20 rtti.m
--- compiler/rtti.m	14 Aug 2002 02:14:56 -0000	1.20
+++ compiler/rtti.m	27 Oct 2002 03:10:06 -0000
@@ -138,9 +138,7 @@
 	% addresses, the third component is in two parts: a list of function
 	% symbols so represented, and a table indexed by the primary tag for
 	% all the other function symbols. The runtime system must check every
-	% element on the list before looking at tn /var/spool/htdig.  Also
-	% improve error reporting.        than /var/spool/htdig.  Also improve
-	% error reporting.he primary tag.
+	% element on the list before looking at the primary tag.
 	%
 	% For notag types, the single functor descriptor fills the roles of
 	% the second, third and fourth components.
@@ -1049,21 +1047,26 @@
 type_ctor_details_num_ptags(du(_, _, PtagMap, _)) = LastPtag + 1 :-
 	map__keys(PtagMap, Ptags),
 	list__last_det(Ptags, LastPtag).
-type_ctor_details_num_ptags(reserved(_, _, _, PtagMap, _)) = LastPtag + 1 :-
+type_ctor_details_num_ptags(reserved(_, _, _, PtagMap, _)) = NumPtags :-
 	map__keys(PtagMap, Ptags),
-	list__last_det(Ptags, LastPtag).
+	( Ptags = [] ->
+		NumPtags = -1
+	;
+		list__last_det(Ptags, LastPtag),
+		NumPtags = LastPtag + 1
+	).
 type_ctor_details_num_ptags(notag(_, _)) = -1.
 type_ctor_details_num_ptags(eqv(_)) = -1.
 type_ctor_details_num_ptags(builtin(_)) = -1.
 type_ctor_details_num_ptags(impl_artifact(_)) = -1.
 type_ctor_details_num_ptags(foreign) = -1.
 
-type_ctor_details_num_functors(enum(_, EnumFunctors, _, _)) =
-	list__length(EnumFunctors).
-type_ctor_details_num_functors(du(_, DuFunctors, _, _)) =
-	list__length(DuFunctors).
-type_ctor_details_num_functors(reserved(_, ResFunctors, _, _, _)) =
-	list__length(ResFunctors).
+type_ctor_details_num_functors(enum(_, Functors, _, _)) =
+	list__length(Functors).
+type_ctor_details_num_functors(du(_, Functors, _, _)) =
+	list__length(Functors).
+type_ctor_details_num_functors(reserved(_, Functors, _, _, _)) =
+	list__length(Functors).
 type_ctor_details_num_functors(notag(_, _)) = 1.
 type_ctor_details_num_functors(eqv(_)) = -1.
 type_ctor_details_num_functors(builtin(_)) = -1.

-- 
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