Article View: comp.std.c
Article #1972Re: legality of assignment of function to a void *.
From: Michael J Zehr
Date: Wed, 14 Nov 1990 03:11
Date: Wed, 14 Nov 1990 03:11
25 lines
1827 bytes
1827 bytes
In article <1990Nov13.174920.2235@zoo.toronto.edu> henry@zoo.toronto.edu (Henry Spencer) writes:
>In article <1990Nov12.211511.2344@batcomputer.tn.cornell.edu> lijewski@theory.tn.cornell.edu (Mike Lijewski) writes:
>>double f(double x) { return x * x; }
>> void *ptr = f;
>
>Function pointers are a whole different universe from normal pointers, in
>principle.
I've tried to follow the new ansi rules pretty carefully and I wasn't
aware of this until recently when it was pointed out here(*). My main
source of confusion was K&R2 (p. 199, "Any pointer may be converted to
type void * without loss of information. If the result is converted
back to the original pointer type, the original pointer is recovered.")
This seems very misleading to me. (Yes, I know that K&R2 is not the
official ANSI specification for C.) Does anyone know if this was
something that was changed after K&R2 was written? What about other
statements in K&R2 that are misleading or conflict with the standard?
-michael j zehr
(*) And fortunately or unfortunately, depending on how you look at it, I
do most of my work on a VAX, where a pointer is a pointer is a pointer,
so I never had problems with any code I wrote, nor did the compiler ever
complain.
Technical Details
Message-ID:
<1990Nov14.031125.14027@athena.mit.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!sdd.hp.com!ucsd!ucbvax!bloom-beacon!tadaReferences:
<1990Nov12.211511.2344@batcomputer.tn.cornell.edu> <1990Nov13.174920.2235@zoo.toronto.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!sdd.hp.com!ucsd!ucbvax!bloom-beacon!tada From: tada@athena.mit.edu (Michael J Zehr) Newsgroups: comp.std.c Subject: Re: legality of assignment of function to a void *. Summary: K&R2 misleadiing Message-ID: <1990Nov14.031125.14027@athena.mit.edu> Date: 14 Nov 90 03:11:25 GMT References: <1990Nov12.211511.2344@batcomputer.tn.cornell.edu> <1990Nov13.174920.2235@zoo.toronto.edu> Sender: daemon@athena.mit.edu (Mr Background) Organization: Massachusetts Institute of Technology Lines: 25