From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fa528,976f7334973592b2,start X-Google-Attributes: gidfa528,public X-Google-ArrivalTime: 2001-07-12 13:40:13 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsxfer.eecs.umich.edu!hardy.tc.umn.edu!news.nodak.edu!not-for-mail From: mooney@dogbert.cc.ndsu.NoDak.edu (Tim Mooney) Newsgroups: comp.unix.tru64 Subject: question about particular ptrmismatch warning Date: 12 Jul 2001 20:20:11 GMT Organization: North Dakota Higher Education Computing Network (NDHECN) Message-ID: <9il0pr$6b8$1@news.ndsu.nodak.edu> NNTP-Posting-Host: dogbert.cc.ndsu.nodak.edu Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: news.ndsu.nodak.edu 994969211 6504 134.129.106.23 (12 Jul 2001 20:20:11 GMT) X-Complaints-To: abuse@nodak.edu NNTP-Posting-Date: 12 Jul 2001 20:20:11 GMT X-Newsreader: trn 4.0-test74 (May 26, 2000) Originator: mooney@dogbert.cc.ndsu.NoDak.edu (Tim Mooney) Xref: archiver1.google.com comp.unix.tru64:3443 Here's a chance for me to show how rusty I am at C. ;-) Given the following (preprocessed) snippet, starting a function: static int foreachfile_callback (dirname, data1, data2) char *dirname; void * data1; void * data2; { int (*func) ( const char * filename , void * data ) = (int (*) ( const char * filename , void * data ) ) data1; When compiling this on Tru64 UNIX 5.1 with Compaq C V6.3-028 on Compaq Tru64 UNIX V5.1 (Rev. 732) Compiler Driver V6.3-026 (sys) cc Driver and the following flags: cc -DHAVE_CONFIG_H -I. -I. -I. -std1 -O2 -g3 -tune host -arch host -portable -readonly_strings -msg_disable inlinestoclsmod,valuepres -c ltdl.c -DPIC *why* does the compiler generate an Info message regarding the assignment above (and subsequent Warning messages about ptrmismatch when func is used later): cc: Info: ltdl.c, line 2557: In the initializer for func, "data1" of type "pointer to void", is being converted to "pointer to function (pointer to const char, pointer to void) returning int". Such a cast is not permitted by the standard. (nonstandcast) = (int (*) LT_PARAMS((const char *filename, lt_ptr data))) data1; -------------------------------------------------------------------^ It's nice that it says that `Such a cast is not permitted by the standard.', but I'm left wondering what the real problem is. K&R2e has a bit of vague verbiage on page 103 regarding, "...or even, except for void *, to assign a pointer of one type to a pointer of another type without a cast." Well, it *is* a void * that's being converted to a pointer to a function, so it seems to be perfectly in line with what K&R2e says. Is it spelled out more clearly in some subsequent standard (C89, or C9X) why this is "not permitted by the standard"? Thanks, Tim -- Tim Mooney mooney@dogbert.cc.ndsu.NoDak.edu Information Technology Services (701) 231-1076 (Voice) Room 242-J6, IACC Building (701) 231-8541 (Fax) North Dakota State University, Fargo, ND 58105-5164