Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!cbosgd!gatech!seismo!umcp-cs!chris From: chris@umcp-cs.UUCP (Chris Torek) Newsgroups: net.lang.c Subject: Re: To dereference or not dereference, that is the question Message-ID: <44@umcp-cs.UUCP> Date: Mon, 3-Mar-86 21:10:12 EST Article-I.D.: umcp-cs.44 Posted: Mon Mar 3 21:10:12 1986 Date-Received: Wed, 5-Mar-86 05:09:49 EST References: <196@aplvax.UUCP> Organization: U of Maryland, Computer Science Dept., College Park, MD Lines: 45 Keywords: type casts,function pointers In article <196@aplvax.UUCP> ded@aplvax.UUCP (Don E. Davis) writes: >... It doesn't seem to matter if I deference function pointers or not. >This seems wrong to me. ... followed by a code sample including the declaration and call: int (*y)(); ... y(2); The call is wrong. It `just happens' to work in PCC-based compilers. Try compiling the following: main() { int f(), (*p)(); p = f; p(1); (*p)(2); (**p)(3); (****************p)(4); } f(x) int x; { printf("%d\n", x); } Just because it works in your compiler (and in mine) does not mean it is correct.... Of course, the only thing you can do with a pointer to a function is take its address, take its value, or call through it. PCC seems to figure that if you are not doing either of the former, you must be doing the latter, and does not care how many indirections were actually used. While this is a bug in PCC, it does not seem a very important one. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1415) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@mimsy.umd.edu