lint warning messages with malloc()

Usenet Administration meissner at xyzzy.UUCP
Mon Nov 7 11:12:19 AEST 1988


In article <355 at marob.MASA.COM> daveh at marob.masa.com (Dave Hammond) writes:
	/* stuff about lint giving errors calling malloc deleted */
| The program code is not at fault.  The problem is that lint does not
| know about malloc returning a suitably aligned pointer, therefore
| it complains.  You could do some fancy declaration footwork and declare
| 
| X *malloc();

No, No, No, No, No, No!  There are implementations of C on word-based
machines, which use different representations for different types of
pointers.  Since the library routine malloc returns a char *, and you have
declared to return X *, you will get undefined behvior.  This is NOT
guaranteed by K&R, H&S, or X3J11.
-- 
Michael Meissner, Data General.

Uucp:	...!mcnc!rti!xyzzy!meissner
Arpa:	meissner at dg-rtp.DG.COM   (or) meissner%dg-rtp.DG.COM at relay.cs.net



More information about the Comp.lang.c mailing list