Newsgroups: comp.std.c Path: utzoo!henry From: henry@zoo.toronto.edu (Henry Spencer) Subject: Re: legality of assignment of function to a void *. Message-ID: <1990Nov13.174920.2235@zoo.toronto.edu> Organization: U of Toronto Zoology References: <1990Nov12.211511.2344@batcomputer.tn.cornell.edu> Date: Tue, 13 Nov 90 17:49:20 GMT In article <1990Nov12.211511.2344@batcomputer.tn.cornell.edu> lijewski@theory.tn.cornell.edu (Mike Lijewski) writes: >Is a standard conforming compiler required to issue an error >diagnostic for the following code. Thanks. > >double f(double x) { return x * x; } > void *ptr = f; Function pointers are a whole different universe from normal pointers, in principle. Free conversions to and from `void *' are allowed only for normal pointers (see 3.3.16.1 and the cross-reference to it in 3.5.7). Your example is not in the list of allowable combinations of operands for `=' in 3.3.16.1's Constraints section, so you are breaking the law and the compiler is required to diagnose it, unless I have missed some subtlety. Your compiler might choose to allow `void *ptr = (void *)f;', however, as an extension. -- "I don't *want* to be normal!" | Henry Spencer at U of Toronto Zoology "Not to worry." | henry@zoo.toronto.edu utzoo!henry