| To: | Geoff Clare <gwc@xxxxxxxxxxxxx> |
|---|---|
| Subject: | Re: [1003.1(2008)/Issue 7 0000074]: Pointer Types Problem |
| From: | Wojtek Lerch <wojtek@xxxxxxx> |
| Date: | Thu, 02 Jul 2009 10:20:41 -0400 |
| Cc: | austin-group-l@xxxxxxxxxxxxx |
| References: | <e26e5335cda9d0dfe49395e6115066fe@xxxxxx> <1730938080F74546ACC51CB65BA00565@xxxxxx> <20090702094404.GA28393@xxxxxx> |
|
I don't think it's a good idea to introduce unusual restrictions on what
the void* pointer can be converted to. Can I convert it to a "void
const*"? What about a "void *const"? Why would it need to be undefined
behaviour to convert it to a char*, even though standard C intends to
allow converting any valid void* pointer to char*? Also, a few details are missing from the wording in question: * Do these conversion work with null pointers? Are they guaranteed to turn null pointers into null pointers? (If not, then one needs to test the result of dlsym() before converting it to a function pointer, rather than after.) * Is it possible for the converted void* pointer to compare equal to the address to some object? (It can happen on hardware with separate address spaces for code and data -- does POSIX want to support such hardware?) Here's my attempt at putting this into words: Any valid pointer to a function type can be converted to a pointer to void [or maybe also to a character type]. The result can be converted back to a function type, producing a value that compares equal to the original value. If the original pointer is a null pointer, then the converted pointer to void is a null pointer too. If the original pointer points to a function, then the result is not a null pointer, but it is unspecified whether it points to any particular object or not (and therefore the results of dereferencing it are undefined), or whether it is correctly aligned for any type other than a character type. The void* pointer may happen to compare equal to a pointer to some object or to one past the end of some array, but nevertheless is not considered to point to either. Geoff Clare wrote: Wojtek Lerch <wojtek@xxxxxx> wrote, on 01 Jul 2009:(0000129) msbrown (manager) - 2009-06-29 02:27 http://austingroupbugs.net/view.php?id=74#c129 -------------------------------------------------------------------- After the sentence ending on line 18890, add the following: If a pointer to an object or incomplete type is converted to a pointer to void and then to a pointer to a function type the behavior is undefined.I don't think this is right. In C, an assignment or an initialization is specified to always performs a conversion -- even a conversion from a type to the same type is still considered a conversion. Doesn't that mean that the value returned by dlsym() cannot be assigned to anything without invoking undefined behaviour? |
| Previous by Date: | Re: Invalid shell assignments in environment, Glenn Fowler |
|---|---|
| Next by Date: | Re: [1003.1(2008)/Issue 7 0000074]: Pointer Types Problem, Wojtek Lerch |
| Previous by Thread: | Re: [1003.1(2008)/Issue 7 0000074]: Pointer Types Problem, Geoff Clare |
| Next by Thread: | RE: [1003.1(2008)/Issue 7 0000074]: Pointer Types Problem, Wojtek Lerch |
| Indexes: | [Date] [Thread] [All Lists] |