Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!rutgers!cmcl2!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: %p and different pointer representations Message-ID: <9764@smoke.BRL.MIL> Date: 2 Mar 89 14:25:03 GMT References: <9382@bloom-beacon.MIT.EDU> <234@mstan.Morgan.COM> <591@jhereg.Jhereg.MN.ORG> <9730@smoke.BRL.MIL> <248@harrier.ukc.ac.uk> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 29 In article <248@harrier.ukc.ac.uk> mtr@ukc.ac.uk (M.T.Russell) writes: >In article <9730@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes: >>A function pointer may well not fit into a void*. >This presumably implies that comparison and assignment between function >pointers and void* pointers is illegal, and thus that > f = NULL; >and > if (f == NULL) >are both illegal if f is a function pointer and NULL is defined as (void *)0. >If this is so, then I don't see that (void *)0 is a reasonable definition >of NULL. >Is (void *)0 a special case? Gcc 1.32 -ansi -pedantic doesn't think so - >it objects to the above constructs. Yes, null pointer constants are special cases. (void*)0 is not really a pointer of type void*, it's just one way of writing a null pointer constant and thus has special properties. In particular it can be assigned to ANY non-const pointer variable and compared against ANY pointer type. It compares unequal to a pointer to any object or function. A valid pointer expression of any type has a value that fits exactly one of the following categories: (1) valid pointer to object or function (2) null pointer An uninitialized static-duration pointer variable starts out with a value that is a null pointer; other pointer variables acquire null-pointer values only by having one assigned to them, either directly as a null pointer constant or indirectly via some other null-valued variable. GCC 1.32 sounds broken here.