Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!rpi!bu.edu!orc!bbn.com!drilex!dricejb From: dricejb@drilex.UUCP (Craig Jackson drilex1) Newsgroups: comp.lang.c Subject: Re: FAQ - malloc array - clarify Keywords: malloc, Sun, lint Message-ID: <15495@drilex.UUCP> Date: 14 Sep 90 13:43:00 GMT References: <8056@helios.TAMU.EDU> <1990Sep08.022034.8444@virtech.uucp> <1803@tuvie> <1990Sep11.002544.9151@virtech.uucp> <1806@tuvie> Organization: DRI/McGraw-Hill, Lexington, MA Lines: 18 A poster recently wondered why a statement like double *ptr = (double *) malloc(ncols * sizeof(double)); gave lint complaints about the argument to malloc(). People here have been blathering on about broken compilers, erroneous lint libraries, etc, thinking that 'sizeof()' is returning an int on that machine. Wouldn't a more reasonable explanation be that 'ncols' is an int, and that particular compiler treats 'int * unsigned' as 'int' (or 'long int')? I don't have all of the rules about value-preserving vs unsignedness-preserving burned into my head, but such an explanation sure makes sense to me... -- Craig Jackson dricejb@drilex.dri.mgh.com {bbn,axiom,redsox,atexnet,ka3ovk}!drilex!{dricej,dricejb}