Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!husc6!ut-sally!pyramid!decwrl!sun!guy From: guy@sun.uucp (Guy Harris) Newsgroups: net.lang.c Subject: Re: Dead functions and /*NOTREACHED*/ Message-ID: <6888@sun.uucp> Date: Thu, 4-Sep-86 12:37:29 EDT Article-I.D.: sun.6888 Posted: Thu Sep 4 12:37:29 1986 Date-Received: Fri, 5-Sep-86 03:20:09 EDT References: <410@epimass.UUCP> <86900037@haddock> Organization: Sun Microsystems, Inc. Lines: 30 > >While I'm at it, a similar comment could be added to tell lint that > >a function like malloc or calloc always returns an aligned pointer. > > Perhaps. *Some* way to tell lint to shut the @#!!%%#@ up about pointer alignment problems, even if the most stringent checking is enabled, is required; complaints about "possible pointer alignment problems" when "malloc" is used are pure noise. > >I understand that ANSI C has a different solution for this, > > No. "void *" has nothing to do with guaranteed alignment, it just means > "pointer to unknown". ANSI C doesn't seem to have much to say about pointer alignment in general - at least I couldn't find anything about it in the obvious places suggested by the index (this may be a bug in the index). However, nothing prevents a compiler or "lint" from treating *all* "void *" pointers as always being properly aligned; the most common uses of "void *" are 1) as the result of a storage-allocation function - in this case, it can be assumed that the function is returning something properly aligned, and 2) as an "opaque pointer", used when a data structure is used to refer to objects of several different types (and the set of object types cannot be determined when the code is written, so a union can't be used) - in this case, the compiler can't do the checking properly anyway, so warnings are largely useless. -- Guy Harris {ihnp4, decvax, seismo, decwrl, ...}!sun!guy guy@sun.com (or guy@sun.arpa)