| To: | Wojtek Lerch <wojtek@xxxxxxx>, "Fred J. Tydeman" <tydeman@xxxxxxxxx>, David-Sarah Hopwood <david-sarah@xxxxxxxxxxxxx>, Douglas Walls <douglas.walls@xxxxxxx> |
|---|---|
| Subject: | Re: [1003.1(2008)/Issue 7 0000074]: Pointer Types Problem |
| From: | Don Cragun <dcragun@xxxxxxxxx> |
| Date: | Wed, 16 Sep 2009 16:51:07 -0700 |
| Cc: | austin-group-l@xxxxxxxxxxxxx |
| References: | <200908291615.n7TGF2505190@smtp.opengroup.org> <BBC385D8F5FE49EFA274AA7CBDC54F4F@ott.qnx.com> |
|
Wojtek, Fred, David, and Douglas, I apologize for my confusion here. I have had discussions with some of you concerning these points over the last decade, but I lost access to the logs of some of those discussions when Sun went through a work- force reduction earlier this year. I believe the open points are the following: 1. Was the resolution of Austin Group Interpretation #003: http://www.opengroup.org/austin/interps/uploads/40/1068/ai-003.txt correct when it was written? In particular was the statement: fptr = (int (*)(int))dlsym(handle, "my_function"); required to generate a diagnostic by the C99 Standard as of July 9, 2002? And, was the statement: *(void **)(&fptr) = dlsym(handle, "my_function"); a functionally equivalent substitute that did not require a diagnostic? In both cases, I'm using "diagnostic" in the sense of the C standard; not the POSIX standard. 2. Does the current C standard (i.e., the approved C99 standard including approved TCs; but not including drafts of upcoming changes) require a compiler to generate a diagnostic for either of the statements: fptr = (int (*)(int))dlsym(handle, "my_function"); *(void **)(&fptr) = dlsym(handle, "my_function"); today? Thanks, Don On Aug 29, 2009, at 2:34 PM, Wojtek Lerch wrote: Fred J. Tydeman wrote:On Sat, 29 Aug 2009 10:22:34 +0100, Geoff Clare wrote:...There is an important difference: 6.5.16.1 has a long list of combinations of types that are allowed in a simple assignment, and none of them mixes a function pointer with a data pointer, whereas the constraints of 6.5.4 allow casts from any scalar type to any other scalar type, including all possible pointer types. This means that converting between a function pointer and a data pointer by simple assignment violates the constraints of 6.5.16.1 and therefore requires a diagnostic, while a similar conversion by an explicit cast is not a constraint violation, and does not require a diagnostic, even when it has undefined behaviour.Personally, I can't find anything in C99 that requires the warning, but just because I can't find it doesn't mean it's not there.I am using WG14 N1362 (C1x) as my reference document, as it is C99 plus all the Technical Corrigendums plus some of the approved changes for the next version of C. A conversion of a pointer can be done via 6.5.4 (Cast operators) or 6.5.16.1 (Simple assignment). Neither of those two has an explicit constraint on pointer to void being converted to pointer to function. |
| Previous by Date: | Re: [1003.1(2008)/Issue 7 0000074]: Pointer Types Problem, Don Cragun |
|---|---|
| Next by Date: | Re: [1003.1(2008)/Issue 7 0000074]: Pointer Types Problem, Don Cragun |
| Previous by Thread: | Re: [1003.1(2008)/Issue 7 0000074]: Pointer Types Problem, Don Cragun |
| Next by Thread: | Re: [1003.1(2008)/Issue 7 0000074]: Pointer Types Problem, Don Cragun |
| Indexes: | [Date] [Thread] [All Lists] |