Email List: Xaustin-group-lX
[All Lists]

RE: [1003.1(2008)/Issue 7 0000074]: Pointer Types Problem

To: "Geoff Clare" <gwc@xxxxxxxxxxxxx>, <austin-group-l@xxxxxxxxxxxxx>
Subject: RE: [1003.1(2008)/Issue 7 0000074]: Pointer Types Problem
From: "Wojtek Lerch" <Wojtek@xxxxxxx>
Date: Fri, 28 Aug 2009 10:40:44 -0400
References: <f6e89684e7d6fc9a7b734e179e7e9c6f@austingroupbugs.net> <20090827145851.GA24688@squonk.masqnet>
Thread-index: AconJzkAnAMXQK+YTHyh5x/Z8460JAAxB3wg
Thread-topic: [1003.1(2008)/Issue 7 0000074]: Pointer Types Problem
> -----Original Message-----
> From: Geoff Clare [mailto:gwc@opengroup.org] 
> >     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");
> 
> I suggest adding:
> 
>       However, conversion using a cast like this is the only
>       portable way of obtaining a function pointer from dlsym().

I also suggest removing the lie about the ISO C standard.  The above
conversion has undefined behaviour in ISO C but it does not "require a
warning".  ISO C does *allow* warnings (a.k.a. diagnostics) in this
situation, and some compilers may take advantage of it, but that's just
because ISO C allows compilers to generate diagnostics whenever they
feel like it.

<Prev in Thread] Current Thread [Next in Thread>