From: Jeff Cohen Date: Mon, 9 Apr 2007 19:26:30 +0000 (+0000) Subject: When the number of elements is zero, don't malloc 32GB on 64-bit systems. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=44f5fb46b0dfed4b949422eee5d38abecd51dab6;p=oota-llvm.git When the number of elements is zero, don't malloc 32GB on 64-bit systems. Fixes unexpected failures on FreeBSD/amd64 of: CFrontend/2005-09-24-BitFieldCrash.c: CFrontend/2007-02-04-EmptyStruct.c: CFrontend/2007-03-26-ZeroWidthBitfield.c: CodeGen/Generic/2005-10-18-ZeroSizeStackObject.ll: git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35828 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp index b1f08079f0e..10ee707aea4 100644 --- a/lib/Target/TargetData.cpp +++ b/lib/Target/TargetData.cpp @@ -342,7 +342,7 @@ const StructLayout *TargetData::getStructLayout(const StructType *Ty) const { // Otherwise, create the struct layout. Because it is variable length, we // malloc it, then use placement new. - unsigned NumElts = Ty->getNumElements(); + int NumElts = Ty->getNumElements(); StructLayout *L = (StructLayout *)malloc(sizeof(StructLayout)+(NumElts-1)*sizeof(uint64_t));