legality of assignment of function to a void *.
Henry Spencer
henry at zoo.toronto.edu
Wed Nov 14 04:49:20 AEST 1990
In article <1990Nov12.211511.2344 at batcomputer.tn.cornell.edu> lijewski at 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 at zoo.toronto.edu utzoo!henry
More information about the Comp.std.c
mailing list