From 0d62bdb2c5b17caf2595855f4dd30b65e6a70aeb Mon Sep 17 00:00:00 2001 From: simonpj Date: Mon, 28 Jan 2002 16:52:37 +0000 Subject: [PATCH] [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. --- ghc/compiler/codeGen/CgRetConv.lhs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ghc/compiler/codeGen/CgRetConv.lhs b/ghc/compiler/codeGen/CgRetConv.lhs index 6108567..f3ef813 100644 --- a/ghc/compiler/codeGen/CgRetConv.lhs +++ b/ghc/compiler/codeGen/CgRetConv.lhs @@ -1,7 +1,7 @@ % % (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} %************************************************************************ -- 1.7.10.4