libtool-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: pointer conversion errors


From: Tom Kacvinsky
Subject: Re: pointer conversion errors
Date: Tue, 01 Nov 2005 08:43:23 -0500
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

I can try the patch on HP-UX and Tru64.

Ralf Wildenhues wrote:
Hi Gary, Tom, Paul,

[ Paul, the rest of this thread will be readable soon at
http://lists.gnu.org/archive/html/libtool-patches/2005-11/msg00002.html
We'd be interested in your opinion on this matter -- thanks. ]

* Gary V. Vaughan wrote on Tue, Nov 01, 2005 at 12:39:06PM CET:

Ralf Wildenhues wrote:

Anyway, I'll apply this to branch-1-5 and HEAD unless someone disagrees.
Without it, IBM compilers barf over this in picky mode.  I believe it
even be necessary as per C standard.

POSIX allows for function pointers to be a different size to void pointers,
so it is not safe to cast from one to another and back again.


AFAIK it's the other way round: ISO C allows different size and may
prohibit convertibility, but XSI provides dlsym(3) and thus has to
require convertibility.  OTOH, ISO C conforming implementations _have_
to output a warning for a conversion without a cast.

At least this is how I read this piece of SUSv3 dlsym(3) Rationale:

| The ISO C standard does not require that pointers to functions can be
| cast back and forth to pointers to data. Indeed, the ISO C standard does
| not require that an object of type void * can hold a pointer to a
| function. Implementations supporting the XSI extension, however, do
| require that an object of type void * can hold a pointer to a function.
| The result of converting a pointer to a function into a pointer to
| another data type (except void *) is still undefined, however. Note that
| compilers conforming to the ISO C standard are required to generate a
| warning if a conversion from a void * pointer to a function pointer is
| attempted as in:
|   fptr = (int (*)(int))dlsym(handle, "my_function");
| Due to the problem noted here, a future version may either add a new
| function to return function pointers, or the current interface may be
| deprecated in favor of two new functions: one that returns data pointers
| and the other that returns function pointers.

And indeed, some systems (was it ia64?) use generic pointers to fat
function pointers, for example.

Look, libltdl has never been fit for the
  sizeof (void *) < sizeof (int (*)(void))
case.

The rest of this topic is covered in this online TODO list entry +
thread:
| * libltdl: make work on systems where function pointers are different from 
object pointers
|   - ltdl void* -> function* separation more work, will need to break API+ABI
|   - http://lists.gnu.org/archive/html/bug-libtool/2005-04/msg00025.html


Technically the code is already broken in this respect, so perhaps we don't
lose anything by applying this patch.  I'm okay with it as long as it is
tested on common archs (pref. including x86_64, sparc, Tru64 and HPUX) first, as they are the most likely to exhibit problems.


Will do before applying.  I don't have access to Tru64, HPUX though.


Maybe it is worth asking Bruno Haible or Paul Eggert for an opinion?


I've Cc:ed Paul in this message.

Cheers,
Ralf






reply via email to

[Prev in Thread] Current Thread [Next in Thread]