Commit 0d62bdb2 authored by simonpj's avatar simonpj
Browse files

[project @ 2002-01-28 16:52:37 by simonpj]

----------------------
	Zero-constructor types
	----------------------

If we have

	data T
	data S = MkS !T

we were getting a crash in the compiler because ctrlRetConvAlg
didn't know what to do for zero-constructor types.

This fix arbitrarily says that they use a non-vectored return,
which fixes the crash.  (Since they only have bottom values,
the return never gets exercised, but GC and exception handling
should work.)

What is still unclear is how we handle data types that are defined
with zero constructors in an hi-boot file.  I think that Bad Things
may well happen if you do a 'seq' on them before we get up to the
definition.  (e.g. as a result of this fix we'll say "unvectored"
whereas the truth may be "vectored".)  This obviously doesn't happen
much (because at present we'd get a compiler crash in ctrlRetConvAlg,
but we should look into it.
parent 6d550803
%
% (c) The GRASP Project, Glasgow University, 1992-1998
%
% $Id: CgRetConv.lhs,v 1.30 2001/08/17 17:18:52 apt Exp $
% $Id: CgRetConv.lhs,v 1.31 2002/01/28 16:52:37 simonpj Exp $
%
\section[CgRetConv]{Return conventions for the code generator}
......@@ -58,12 +58,16 @@ ctrlReturnConvAlg :: TyCon -> CtrlReturnConvention
ctrlReturnConvAlg tycon
= case (tyConFamilySize tycon) of
0 -> pprPanic "ctrlRetConvAlg" (ppr tycon)
size -> -- we're supposed to know...
if (size > (1::Int) && size <= mAX_FAMILY_SIZE_FOR_VEC_RETURNS) then
VectoredReturn size
else
UnvectoredReturn size
UnvectoredReturn size
-- NB: unvectored returns Include size 0 (no constructors), so that
-- the following perverse code compiles (it crashed GHC in 5.02)
-- data T1
-- data T2 = T2 !T1 Int
-- The only value of type T1 is bottom, which never returns anyway.
\end{code}
%************************************************************************
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment